diff options
author | Steven Bennetts <steve@lindenlab.com> | 2009-09-11 23:56:28 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2009-09-11 23:56:28 +0000 |
commit | 245172949fa6b4ee4fde7da66f7abb804503ed9a (patch) | |
tree | b626db2b79442ca815949c7b40c51192954b1f30 /indra/newview/llpanelteleporthistory.cpp | |
parent | 7df79382a075646a51f21bed0d7f8de883fc3608 (diff) |
merge -r 1649-1651 https://svn.aws.productengine.com/secondlife/pe/stable-2@1648 -> viewer-2.0.0-3
Fixes: EXT-843 EXT-846
New Dev: EXT-514
Diffstat (limited to 'indra/newview/llpanelteleporthistory.cpp')
-rw-r--r-- | indra/newview/llpanelteleporthistory.cpp | 173 |
1 files changed, 131 insertions, 42 deletions
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp index df48ee5d08..1fd7928bfc 100644 --- a/indra/newview/llpanelteleporthistory.cpp +++ b/indra/newview/llpanelteleporthistory.cpp @@ -38,6 +38,8 @@ #include "llsidetray.h" #include "llworldmap.h" #include "llteleporthistorystorage.h" +#include "llaccordionctrl.h" +#include "llaccordionctrltab.h" // Not yet implemented; need to remove buildPanel() from constructor when we switch //static LLRegisterPanelClassWrapper<LLTeleportHistoryPanel> t_teleport_history("panel_teleport_history"); @@ -46,7 +48,8 @@ LLTeleportHistoryPanel::LLTeleportHistoryPanel() : LLPanelPlacesTab(), mFilterSubString(LLStringUtil::null), mTeleportHistory(NULL), - mHistoryItems(NULL) + mHistoryAccordeon(NULL), + mLastSelectedScrollList(NULL) { LLUICtrlFactory::getInstance()->buildPanel(this, "panel_teleport_history.xml"); } @@ -63,12 +66,28 @@ BOOL LLTeleportHistoryPanel::postBuild() mTeleportHistory->setHistoryChangedCallback(boost::bind(&LLTeleportHistoryPanel::showTeleportHistory, this)); } - mHistoryItems = getChild<LLScrollListCtrl>("history_items"); - if (mHistoryItems) + mHistoryAccordeon = getChild<LLAccordionCtrl>("history_accordion"); + + if (mHistoryAccordeon) { - mHistoryItems->setDoubleClickCallback(onDoubleClickItem, this); - mHistoryItems->setCommitOnSelectionChange(FALSE); - mHistoryItems->setCommitCallback(boost::bind(&LLTeleportHistoryPanel::handleItemSelect, this, _2)); + + for (child_list_const_iter_t iter = mHistoryAccordeon->beginChild(); iter != mHistoryAccordeon->endChild(); iter++) + { + if (dynamic_cast<LLAccordionCtrlTab*>(*iter)) + { + LLAccordionCtrlTab* tab = (LLAccordionCtrlTab*)*iter; + mItemContainers.put(tab); + + LLScrollListCtrl* sl = getScrollListFromTab(tab); + if (sl) + { + sl->setDoubleClickCallback(onDoubleClickItem, this); + sl->setCommitOnSelectionChange(FALSE); + sl->setCommitCallback(boost::bind(&LLTeleportHistoryPanel::handleItemSelect, this, sl)); + } + + } + } } return TRUE; @@ -87,13 +106,16 @@ void LLTeleportHistoryPanel::onSearchEdit(const std::string& string) // virtual void LLTeleportHistoryPanel::onShowOnMap() { - LLScrollListItem* itemp = mHistoryItems->getFirstSelected(); + if (!mLastSelectedScrollList) + return; + + LLScrollListItem* itemp = mLastSelectedScrollList->getFirstSelected(); if(!itemp) return; S32 index = itemp->getColumn(LIST_INDEX)->getValue().asInteger(); - LLVector3d global_pos = mTeleportHistory->getItems()[index].mGlobalPos; + LLVector3d global_pos = mTeleportHistory->getItems()[mTeleportHistory->getItems().size() - 1 - index].mGlobalPos; if (!global_pos.isExactlyZero()) { @@ -105,14 +127,17 @@ void LLTeleportHistoryPanel::onShowOnMap() // virtual void LLTeleportHistoryPanel::onTeleport() { - LLScrollListItem* itemp = mHistoryItems->getFirstSelected(); + if (!mLastSelectedScrollList) + return; + + LLScrollListItem* itemp = mLastSelectedScrollList->getFirstSelected(); if(!itemp) return; S32 index = itemp->getColumn(LIST_INDEX)->getValue().asInteger(); // teleport to existing item in history, so we don't add it again - mTeleportHistory->goToItem(index); + mTeleportHistory->goToItem(mTeleportHistory->getItems().size() - 1 - index); } /* @@ -145,28 +170,41 @@ void LLTeleportHistoryPanel::updateVerbs() if (!isTabVisible()) return; - S32 index = 0; - S32 cur_item = 0; - - LLScrollListItem* itemp = mHistoryItems->getFirstSelected(); - if (itemp) + if (!mLastSelectedScrollList) { - index = itemp->getColumn(LIST_INDEX)->getValue().asInteger(); - cur_item = mTeleportHistory->getItems().size() - 1; + mTeleportBtn->setEnabled(false); + mShowOnMapBtn->setEnabled(false); + return; } - mTeleportBtn->setEnabled(index != cur_item); - mShowOnMapBtn->setEnabled(itemp != NULL); + LLScrollListItem* itemp = mLastSelectedScrollList->getFirstSelected(); + + mTeleportBtn->setEnabled(NULL != itemp && 0 < itemp->getColumn(LIST_INDEX)->getValue().asInteger()); + mShowOnMapBtn->setEnabled(NULL != itemp); } void LLTeleportHistoryPanel::showTeleportHistory() { + if (!mHistoryAccordeon) + return; + const LLTeleportHistoryStorage::slurl_list_t& hist_items = mTeleportHistory->getItems(); - mHistoryItems->deleteAllItems(); + const U32 seconds_in_day = 24 * 60 * 60; + LLDate curr_date = LLDate::now(); + + curr_date.secondsSinceEpoch(curr_date.secondsSinceEpoch() + seconds_in_day); + + S32 curr_tab = -1; + S32 tabs_cnt = mItemContainers.size(); + S32 curr_year = 0, curr_month = 0, curr_day = 0; + + LLScrollListCtrl *curr_scroll_list = NULL; - for (LLTeleportHistoryStorage::slurl_list_t::const_iterator iter = hist_items.begin(); - iter != hist_items.end(); ++iter) + S32 index = 0; + + for (LLTeleportHistoryStorage::slurl_list_t::const_reverse_iterator iter = hist_items.rbegin(); + iter != hist_items.rend(); ++iter) { std::string landmark_title = (*iter).mTitle; LLStringUtil::toUpper(landmark_title); @@ -176,45 +214,83 @@ void LLTeleportHistoryPanel::showTeleportHistory() if (!passed) continue; + + if (curr_tab < tabs_cnt - 1) + { + const LLDate &date = (*iter).mDate; + + S32 year, month, day; + if (!date.split(&year, &month, &day)) + { + llwarns << "Failed to split date: " << date << llendl; + continue; + } + + if (day != curr_day || month != curr_month || year != curr_year) + { + LLAccordionCtrlTab* tab = NULL; + while (curr_tab < tabs_cnt - 1 && (day != curr_day || month != curr_month || year != curr_year)) + { + curr_tab++; + + tab = mItemContainers.get(mItemContainers.size() - 1 - curr_tab); + tab->setVisible(false); + + curr_date.secondsSinceEpoch(curr_date.secondsSinceEpoch() - seconds_in_day); + curr_date.split(&curr_year, &curr_month, &curr_day); + } + + tab->setVisible(true); + + curr_scroll_list = getScrollListFromTab(tab); + if (curr_scroll_list) + { + curr_scroll_list->deleteAllItems(); + } + } + } - S32 index = iter - hist_items.begin(); LLSD row; row["id"] = index; - LLSD& icon_column = row["columns"][LIST_ICON]; - icon_column["column"] = "landmark_icon"; - icon_column["type"] = "icon"; - icon_column["value"] = "inv_item_landmark.tga"; + if (curr_scroll_list) + { + LLSD& icon_column = row["columns"][LIST_ICON]; + icon_column["column"] = "landmark_icon"; + icon_column["type"] = "icon"; + icon_column["value"] = "inv_item_landmark.tga"; + + LLSD& region_column = row["columns"][LIST_ITEM_TITLE]; + region_column["column"] = "region"; + region_column["type"] = "text"; + region_column["value"] = (*iter).mTitle; - LLSD& region_column = row["columns"][LIST_ITEM_TITLE]; - region_column["column"] = "region"; - region_column["type"] = "text"; - region_column["value"] = (*iter).mTitle; + LLSD& index_column = row["columns"][LIST_INDEX]; + index_column["column"] = "index"; + index_column["type"] = "text"; + index_column["value"] = index; - LLSD& index_column = row["columns"][LIST_INDEX]; - index_column["column"] = "index"; - index_column["type"] = "text"; - index_column["value"] = index; + index++; - mHistoryItems->addElement(row, ADD_TOP); + curr_scroll_list->addElement(row); + } } - // Consider last item (most recent) as current - LLScrollListItem* itemp = mHistoryItems->getItem((S32)hist_items.size() - 1); - ((LLScrollListText*)itemp->getColumn(LIST_ITEM_TITLE))->setFontStyle(LLFontGL::BOLD); + mHistoryAccordeon->arrange(); updateVerbs(); } -void LLTeleportHistoryPanel::handleItemSelect(const LLSD& data) +void LLTeleportHistoryPanel::handleItemSelect(LLScrollListCtrl* sl) { + mLastSelectedScrollList = sl; updateVerbs(); } //static void LLTeleportHistoryPanel::onDoubleClickItem(void* user_data) { - LLTeleportHistoryPanel* self = (LLTeleportHistoryPanel*)user_data; + /*LLTeleportHistoryPanel* self = (LLTeleportHistoryPanel*)user_data; LLScrollListItem* itemp = self->mHistoryItems->getFirstSelected(); if(!itemp) @@ -224,5 +300,18 @@ void LLTeleportHistoryPanel::onDoubleClickItem(void* user_data) key["type"] = "teleport_history"; key["id"] = itemp->getColumn(LIST_INDEX)->getValue().asInteger(); - LLSideTray::getInstance()->showPanel("panel_places", key); + LLSideTray::getInstance()->showPanel("panel_places", key);*/ +} + +LLScrollListCtrl* LLTeleportHistoryPanel::getScrollListFromTab(LLAccordionCtrlTab *tab) +{ + for (child_list_const_iter_t iter = tab->beginChild(); iter != tab->endChild(); iter++) + { + if (dynamic_cast<LLScrollListCtrl*>(*iter)) + { + return (LLScrollListCtrl*)*iter; // There should be one scroll list per tab. + } + } + + return NULL; } |