void LLTeleportHistoryPanel::handleItemSelect(LLFlatListView* selected) { mLastSelectedFlatlList = selected; LLTeleportHistoryFlatItem* item = dynamic_cast<LLTeleportHistoryFlatItem *> (mLastSelectedFlatlList->getSelectedItem()); if (item) mLastSelectedItemIndex = item->getIndex(); S32 tabs_cnt = mItemContainers.size(); for (S32 n = 0; n < tabs_cnt; n++) { LLAccordionCtrlTab* tab = mItemContainers.get(n); if (!tab->getVisible()) continue; LLFlatListView *flv = getFlatListViewFromTab(tab); if (!flv) continue; if (flv == selected) continue; flv->resetSelection(true); } updateVerbs(); }
bool LLTeleportHistoryPanel::isActionEnabled(const LLSD& userdata) const { S32 tabs_cnt = mItemContainers.size(); bool has_expanded_tabs = false; bool has_collapsed_tabs = false; for (S32 n = 0; n < tabs_cnt; n++) { LLAccordionCtrlTab* tab = mItemContainers.get(n); if (!tab->getVisible()) continue; if (tab->getDisplayChildren()) { has_expanded_tabs = true; } else { has_collapsed_tabs = true; } if (has_expanded_tabs && has_collapsed_tabs) { break; } } std::string command_name = userdata.asString(); if (has_expanded_tabs && command_name == "collapse_all") { return true; } if (has_collapsed_tabs && command_name == "expand_all") { return true; } return false; }
void LLTeleportHistoryPanel::replaceItem(S32 removed_index) { // Flat list for 'Today' (mItemContainers keeps accordion tabs in reverse order) LLFlatListView* fv = NULL; if (mItemContainers.size() > 0) { 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 = LLTeleportHistoryFlatItemStorage::instance() .getFlatItemForPersistentItem(&mContextMenu, history_items[history_items.size() - 1], // Most recent item, it was added instead of removed history_items.size(), // index will be decremented inside loop below sFilterSubString); 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) { LLTeleportHistoryFlatItemStorage::instance().removeItem(item); 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); } } }