summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelteleporthistory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpanelteleporthistory.cpp')
-rw-r--r--indra/newview/llpanelteleporthistory.cpp67
1 files changed, 58 insertions, 9 deletions
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp
index 67d0e13786..523487fa14 100644
--- a/indra/newview/llpanelteleporthistory.cpp
+++ b/indra/newview/llpanelteleporthistory.cpp
@@ -41,6 +41,7 @@
#include "llaccordionctrl.h"
#include "llaccordionctrltab.h"
#include "llflatlistview.h"
+#include "llnotificationsutil.h"
#include "lltextbox.h"
#include "llviewermenu.h"
#include "llviewerinventory.h"
@@ -51,6 +52,8 @@
// Used to limit time spent for items list update per frame.
static const U32 ADD_LIMIT = 50;
+static const std::string COLLAPSED_BY_USER = "collapsed_by_user";
+
class LLTeleportHistoryFlatItem : public LLPanel
{
public:
@@ -217,7 +220,6 @@ void LLTeleportHistoryPanel::ContextMenu::onCopyToClipboard()
LLTeleportHistoryPanel::LLTeleportHistoryPanel()
: LLPanelPlacesTab(),
- mFilterSubString(LLStringUtil::null),
mDirty(true),
mCurrentItem(0),
mTeleportHistory(NULL),
@@ -253,6 +255,10 @@ BOOL LLTeleportHistoryPanel::postBuild()
LLAccordionCtrlTab* tab = (LLAccordionCtrlTab*)*iter;
tab->setRightMouseDownCallback(boost::bind(&LLTeleportHistoryPanel::onAccordionTabRightClick, this, _1, _2, _3, _4));
tab->setDisplayChildren(false);
+ tab->setDropDownStateChangedCallback(boost::bind(&LLTeleportHistoryPanel::onAccordionExpand, this, _1, _2));
+
+ // All accordion tabs are collapsed initially
+ setAccordionCollapsedByUser(tab, true);
mItemContainers.put(tab);
@@ -269,10 +275,18 @@ BOOL LLTeleportHistoryPanel::postBuild()
// Open first 2 accordion tabs
if (mItemContainers.size() > 1)
- mItemContainers.get(mItemContainers.size() - 1)->setDisplayChildren(true);
+ {
+ LLAccordionCtrlTab* tab = mItemContainers.get(mItemContainers.size() - 1);
+ tab->setDisplayChildren(true);
+ setAccordionCollapsedByUser(tab, false);
+ }
if (mItemContainers.size() > 2)
- mItemContainers.get(mItemContainers.size() - 2)->setDisplayChildren(true);
+ {
+ LLAccordionCtrlTab* tab = mItemContainers.get(mItemContainers.size() - 2);
+ tab->setDisplayChildren(true);
+ setAccordionCollapsedByUser(tab, false);
+ }
}
getChild<LLPanel>("bottom_panel")->childSetAction("gear_btn",boost::bind(&LLTeleportHistoryPanel::onGearButtonClicked, this));
@@ -302,9 +316,9 @@ void LLTeleportHistoryPanel::draw()
// virtual
void LLTeleportHistoryPanel::onSearchEdit(const std::string& string)
{
- if (mFilterSubString != string)
+ if (sFilterSubString != string)
{
- mFilterSubString = string;
+ sFilterSubString = string;
showTeleportHistory();
}
}
@@ -467,8 +481,8 @@ void LLTeleportHistoryPanel::refresh()
std::string landmark_title = items[mCurrentItem].mTitle;
LLStringUtil::toUpper(landmark_title);
- std::string::size_type match_offset = mFilterSubString.size() ? landmark_title.find(mFilterSubString) : std::string::npos;
- bool passed = mFilterSubString.size() == 0 || match_offset != std::string::npos;
+ std::string::size_type match_offset = sFilterSubString.size() ? landmark_title.find(sFilterSubString) : std::string::npos;
+ bool passed = sFilterSubString.size() == 0 || match_offset != std::string::npos;
if (!passed)
{
@@ -490,6 +504,18 @@ void LLTeleportHistoryPanel::refresh()
LLAccordionCtrlTab* tab = mItemContainers.get(mItemContainers.size() - 1 - tab_idx);
tab->setVisible(true);
+ // Expand all accordion tabs when filtering
+ if(!mFilterSubString.empty())
+ {
+ tab->setDisplayChildren(true);
+ }
+ // Restore each tab's expand state when not filtering
+ else
+ {
+ bool collapsed = isAccordionCollapsedByUser(tab);
+ tab->setDisplayChildren(!collapsed);
+ }
+
curr_flat_view = getFlatListViewFromTab(tab);
}
@@ -722,13 +748,13 @@ void LLTeleportHistoryPanel::onCollapseAllFolders()
void LLTeleportHistoryPanel::onClearTeleportHistory()
{
- LLNotifications::instance().add("ConfirmClearTeleportHistory", LLSD(), LLSD(), boost::bind(&LLTeleportHistoryPanel::onClearTeleportHistoryDialog, this, _1, _2));
+ LLNotificationsUtil::add("ConfirmClearTeleportHistory", LLSD(), LLSD(), boost::bind(&LLTeleportHistoryPanel::onClearTeleportHistoryDialog, this, _1, _2));
}
bool LLTeleportHistoryPanel::onClearTeleportHistoryDialog(const LLSD& notification, const LLSD& response)
{
- S32 option = LLNotification::getSelectedOption(notification, response);
+ S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if (0 == option)
{
@@ -774,3 +800,26 @@ void LLTeleportHistoryPanel::onGearButtonClicked()
LLMenuGL::showPopup(this, menu, menu_x, menu_y);
}
+void LLTeleportHistoryPanel::setAccordionCollapsedByUser(LLUICtrl* acc_tab, bool collapsed)
+{
+ LLSD param = acc_tab->getValue();
+ param[COLLAPSED_BY_USER] = collapsed;
+ acc_tab->setValue(param);
+}
+
+bool LLTeleportHistoryPanel::isAccordionCollapsedByUser(LLUICtrl* acc_tab)
+{
+ LLSD param = acc_tab->getValue();
+ if(!param.has("acc_collapsed"))
+ {
+ return false;
+ }
+ return param[COLLAPSED_BY_USER].asBoolean();
+}
+
+void LLTeleportHistoryPanel::onAccordionExpand(LLUICtrl* ctrl, const LLSD& param)
+{
+ bool expanded = param.asBoolean();
+ // Save accordion tab state to restore it in refresh()
+ setAccordionCollapsedByUser(ctrl, !expanded);
+}