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.cpp98
1 files changed, 83 insertions, 15 deletions
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp
index 207ed723b2..a34f029095 100644
--- a/indra/newview/llpanelteleporthistory.cpp
+++ b/indra/newview/llpanelteleporthistory.cpp
@@ -4,7 +4,7 @@
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
*
- * Copyright (c) 2001-2009, Linden Research, Inc.
+ * Copyright (c) 2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
@@ -60,6 +60,7 @@ public:
virtual BOOL postBuild();
S32 getIndex() { return mIndex; }
+ void setIndex(S32 index) { mIndex = index; }
const std::string& getRegionName() { return mRegionName;}
/*virtual*/ void setValue(const LLSD& value);
@@ -70,9 +71,10 @@ public:
static void showPlaceInfoPanel(S32 index);
private:
- void onInfoBtnClick();
+ void onProfileBtnClick();
- LLButton* mInfoBtn;
+ LLButton* mProfileBtn;
+
LLTeleportHistoryPanel::ContextMenu *mContextMenu;
S32 mIndex;
@@ -94,8 +96,9 @@ BOOL LLTeleportHistoryFlatItem::postBuild()
LLTextBox *region = getChild<LLTextBox>("region");
region->setValue(mRegionName);
- mInfoBtn = getChild<LLButton>("info_btn");
- mInfoBtn->setClickedCallback(boost::bind(&LLTeleportHistoryFlatItem::onInfoBtnClick, this));
+ mProfileBtn = getChild<LLButton>("profile_btn");
+
+ mProfileBtn->setClickedCallback(boost::bind(&LLTeleportHistoryFlatItem::onProfileBtnClick, this));
return true;
}
@@ -110,7 +113,7 @@ void LLTeleportHistoryFlatItem::setValue(const LLSD& value)
void LLTeleportHistoryFlatItem::onMouseEnter(S32 x, S32 y, MASK mask)
{
childSetVisible("hovered_icon", true);
- mInfoBtn->setVisible(true);
+ mProfileBtn->setVisible(true);
LLPanel::onMouseEnter(x, y, mask);
}
@@ -118,7 +121,7 @@ void LLTeleportHistoryFlatItem::onMouseEnter(S32 x, S32 y, MASK mask)
void LLTeleportHistoryFlatItem::onMouseLeave(S32 x, S32 y, MASK mask)
{
childSetVisible("hovered_icon", false);
- mInfoBtn->setVisible(false);
+ mProfileBtn->setVisible(false);
LLPanel::onMouseLeave(x, y, mask);
}
@@ -141,7 +144,7 @@ void LLTeleportHistoryFlatItem::showPlaceInfoPanel(S32 index)
LLSideTray::getInstance()->showPanel("panel_places", params);
}
-void LLTeleportHistoryFlatItem::onInfoBtnClick()
+void LLTeleportHistoryFlatItem::onProfileBtnClick()
{
LLTeleportHistoryFlatItem::showPlaceInfoPanel(mIndex);
}
@@ -180,7 +183,7 @@ LLContextMenu* LLTeleportHistoryPanel::ContextMenu::createMenu()
registrar.add("TeleportHistory.Teleport", boost::bind(&LLTeleportHistoryPanel::ContextMenu::onTeleport, this));
registrar.add("TeleportHistory.MoreInformation",boost::bind(&LLTeleportHistoryPanel::ContextMenu::onInfo, this));
- registrar.add("TeleportHistory.Copy", boost::bind(&LLTeleportHistoryPanel::ContextMenu::onCopy, this));
+ registrar.add("TeleportHistory.CopyToClipboard",boost::bind(&LLTeleportHistoryPanel::ContextMenu::onCopyToClipboard, this));
// create the context menu from the XUI
return LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>(
@@ -203,11 +206,11 @@ void LLTeleportHistoryPanel::ContextMenu::gotSLURLCallback(const std::string& sl
gClipboard.copyFromString(utf8str_to_wstring(slurl));
}
-void LLTeleportHistoryPanel::ContextMenu::onCopy()
+void LLTeleportHistoryPanel::ContextMenu::onCopyToClipboard()
{
LLVector3d globalPos = LLTeleportHistoryStorage::getInstance()->getItems()[mIndex].mGlobalPos;
LLLandmarkActions::getSLURLfromPosGlobal(globalPos,
- boost::bind(&LLTeleportHistoryPanel::ContextMenu::gotSLURLCallback, _1), false);
+ boost::bind(&LLTeleportHistoryPanel::ContextMenu::gotSLURLCallback, _1));
}
// Not yet implemented; need to remove buildPanel() from constructor when we switch
@@ -237,7 +240,7 @@ BOOL LLTeleportHistoryPanel::postBuild()
mTeleportHistory = LLTeleportHistoryStorage::getInstance();
if (mTeleportHistory)
{
- mTeleportHistory->setHistoryChangedCallback(boost::bind(&LLTeleportHistoryPanel::onTeleportHistoryChange, this));
+ mTeleportHistory->setHistoryChangedCallback(boost::bind(&LLTeleportHistoryPanel::onTeleportHistoryChange, this, _1));
}
mHistoryAccordion = getChild<LLAccordionCtrl>("history_accordion");
@@ -488,7 +491,7 @@ void LLTeleportHistoryPanel::refresh()
if (mLastSelectedItemIndex == mCurrentItem)
curr_flat_view->selectItem(item, true);
}
-
+
mCurrentItem--;
if (++added_items >= ADD_LIMIT)
@@ -503,10 +506,75 @@ void LLTeleportHistoryPanel::refresh()
mDirty = false;
}
-void LLTeleportHistoryPanel::onTeleportHistoryChange()
+void LLTeleportHistoryPanel::onTeleportHistoryChange(S32 removed_index)
{
mLastSelectedItemIndex = -1;
- showTeleportHistory();
+
+ if (-1 == removed_index)
+ showTeleportHistory(); // recreate all items
+ else
+ replaceItem(removed_index); // replace removed item by most recent
+}
+
+void LLTeleportHistoryPanel::replaceItem(S32 removed_index)
+{
+ // Flat list for 'Today' (mItemContainers keeps accordion tabs in reverse order)
+ LLFlatListView* fv = getFlatListViewFromTab(mItemContainers[mItemContainers.size() - 1]);
+
+ // Empty flat list for 'Today' means that other flat lists are empty as well,
+ // so all items from teleport history should be added.
+ if (!fv || fv->size() == 0)
+ {
+ showTeleportHistory();
+ return;
+ }
+
+ const LLTeleportHistoryStorage::slurl_list_t& history_items = mTeleportHistory->getItems();
+ LLTeleportHistoryFlatItem* item = new LLTeleportHistoryFlatItem(history_items.size(), // index will be decremented inside loop below
+ &mContextMenu,
+ history_items[history_items.size() - 1].mTitle); // Most recent item, it was
+ // added instead of removed
+ fv->addItem(item, LLUUID::null, ADD_TOP);
+
+ // Index of each item, from last to removed item should be decremented
+ // to point to the right item in LLTeleportHistoryStorage
+ for (S32 tab_idx = mItemContainers.size() - 1; tab_idx >= 0; --tab_idx)
+ {
+ LLAccordionCtrlTab* tab = mItemContainers.get(tab_idx);
+ if (!tab->getVisible())
+ continue;
+
+ fv = getFlatListViewFromTab(tab);
+ if (!fv)
+ {
+ showTeleportHistory();
+ return;
+ }
+
+ std::vector<LLPanel*> items;
+ fv->getItems(items);
+
+ S32 items_cnt = items.size();
+ for (S32 n = 0; n < items_cnt; ++n)
+ {
+ LLTeleportHistoryFlatItem *item = (LLTeleportHistoryFlatItem*) items[n];
+
+ if (item->getIndex() == removed_index)
+ {
+ fv->removeItem(item);
+
+ // If flat list becames empty, then accordion tab should be hidden
+ if (fv->size() == 0)
+ tab->setVisible(false);
+
+ mHistoryAccordion->arrange();
+
+ return; // No need to decrement idexes for the rest of items
+ }
+
+ item->setIndex(item->getIndex() - 1);
+ }
+ }
}
void LLTeleportHistoryPanel::showTeleportHistory()