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.cpp82
1 files changed, 46 insertions, 36 deletions
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp
index 627074efa9..8097e0ac0b 100644
--- a/indra/newview/llpanelteleporthistory.cpp
+++ b/indra/newview/llpanelteleporthistory.cpp
@@ -42,6 +42,7 @@
#include "llnotificationsutil.h"
#include "lltextbox.h"
#include "lltoggleablemenu.h"
+#include "llviewercontrol.h"
#include "llviewermenu.h"
#include "lllandmarkactions.h"
#include "llclipboard.h"
@@ -60,7 +61,7 @@ public:
LLDate date, const std::string &hl);
virtual ~LLTeleportHistoryFlatItem();
- virtual BOOL postBuild();
+ virtual bool postBuild();
/*virtual*/ S32 notify(const LLSD& info);
@@ -78,7 +79,7 @@ public:
void onMouseEnter(S32 x, S32 y, MASK mask);
void onMouseLeave(S32 x, S32 y, MASK mask);
- virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
+ virtual bool handleRightMouseDown(S32 x, S32 y, MASK mask);
static void showPlaceInfoPanel(S32 index);
@@ -148,7 +149,7 @@ LLTeleportHistoryFlatItem::~LLTeleportHistoryFlatItem()
}
//virtual
-BOOL LLTeleportHistoryFlatItem::postBuild()
+bool LLTeleportHistoryFlatItem::postBuild()
{
mTitle = getChild<LLTextBox>("region");
@@ -215,8 +216,18 @@ std::string LLTeleportHistoryFlatItem::getTimestamp()
// Only show timestamp for today and yesterday
if(time_diff < seconds_today + seconds_in_day)
{
- timestamp = "[" + LLTrans::getString("TimeHour12")+"]:["
- + LLTrans::getString("TimeMin")+"] ["+ LLTrans::getString("TimeAMPM")+"]";
+ static bool use_24h = gSavedSettings.getBOOL("Use24HourClock");
+ if (use_24h)
+ {
+ timestamp = "[" + LLTrans::getString("TimeHour") + "]:["
+ + LLTrans::getString("TimeMin") + "]";
+ }
+ else
+ {
+ timestamp = "[" + LLTrans::getString("TimeHour12") + "]:["
+ + LLTrans::getString("TimeMin") + "] [" + LLTrans::getString("TimeAMPM") + "]";
+ }
+
LLSD substitution;
substitution["datetime"] = (S32) date.secondsSinceEpoch();
LLStringUtil::format(timestamp, substitution);
@@ -265,11 +276,11 @@ void LLTeleportHistoryFlatItem::onMouseLeave(S32 x, S32 y, MASK mask)
}
// virtual
-BOOL LLTeleportHistoryFlatItem::handleRightMouseDown(S32 x, S32 y, MASK mask)
+bool LLTeleportHistoryFlatItem::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
LLPanel::handleRightMouseDown(x, y, mask);
showMenu(x, y);
- return TRUE;
+ return true;
}
void LLTeleportHistoryFlatItem::showPlaceInfoPanel(S32 index)
@@ -317,7 +328,7 @@ LLTeleportHistoryFlatItemStorage::getFlatItemForPersistentItem (
item->setRegionName(persistent_item.mTitle);
item->setDate(persistent_item.mDate);
item->setHighlightedText(hl);
- item->setVisible(TRUE);
+ item->setVisible(true);
item->updateTitle();
item->updateTimestamp();
}
@@ -400,14 +411,14 @@ LLTeleportHistoryPanel::~LLTeleportHistoryPanel()
mTeleportHistoryChangedConnection.disconnect();
}
-BOOL LLTeleportHistoryPanel::postBuild()
+bool LLTeleportHistoryPanel::postBuild()
{
- mCommitCallbackRegistrar.add("TeleportHistory.GearMenu.Action", boost::bind(&LLTeleportHistoryPanel::onGearMenuAction, this, _2));
+ mCommitCallbackRegistrar.add("TeleportHistory.GearMenu.Action", { boost::bind(&LLTeleportHistoryPanel::onGearMenuAction, this, _2), cb_info::UNTRUSTED_THROTTLE });
mEnableCallbackRegistrar.add("TeleportHistory.GearMenu.Enable", boost::bind(&LLTeleportHistoryPanel::isActionEnabled, this, _2));
// init menus before list, since menus are passed to list
mGearItemMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_teleport_history_item.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
- mGearItemMenu->setAlwaysShowMenu(TRUE); // all items can be disabled if nothing is selected, show anyway
+ mGearItemMenu->setAlwaysShowMenu(true); // all items can be disabled if nothing is selected, show anyway
mSortingMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_teleport_history_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
mTeleportHistory = LLTeleportHistoryStorage::getInstance();
@@ -461,7 +472,7 @@ BOOL LLTeleportHistoryPanel::postBuild()
}
}
- return TRUE;
+ return true;
}
// virtual
@@ -598,7 +609,7 @@ void LLTeleportHistoryPanel::getNextTab(const LLDate& item_date, S32& tab_idx, L
{
const U32 seconds_in_day = 24 * 60 * 60;
- S32 tabs_cnt = mItemContainers.size();
+ S32 tabs_cnt = static_cast<S32>(mItemContainers.size());
S32 curr_year = 0, curr_month = 0, curr_day = 0;
tab_date = LLDate::now();
@@ -695,7 +706,7 @@ void LLTeleportHistoryPanel::refresh()
// tab_boundary_date would be earliest possible date for this tab
S32 tab_idx = 0;
getNextTab(date, tab_idx, tab_boundary_date);
- tab_idx = mItemContainers.size() - 1 - tab_idx;
+ tab_idx = static_cast<S32>(mItemContainers.size()) - 1 - tab_idx;
if (tab_idx >= 0)
{
LLAccordionCtrlTab* tab = mItemContainers.at(tab_idx);
@@ -743,7 +754,7 @@ void LLTeleportHistoryPanel::refresh()
break;
}
- for (S32 n = mItemContainers.size() - 1; n >= 0; --n)
+ for (S32 n = static_cast<S32>(mItemContainers.size()) - 1; n >= 0; --n)
{
LLAccordionCtrlTab* tab = mItemContainers.at(n);
LLFlatListView* fv = getFlatListViewFromTab(tab);
@@ -798,14 +809,14 @@ void LLTeleportHistoryPanel::replaceItem(S32 removed_index)
LLTeleportHistoryFlatItem* item = LLTeleportHistoryFlatItemStorage::instance()
.getFlatItemForPersistentItem(mGearItemMenu,
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
+ static_cast<S32>(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)
+ for (S32 tab_idx = static_cast<S32>(mItemContainers.size()) - 1; tab_idx >= 0; --tab_idx)
{
LLAccordionCtrlTab* tab = mItemContainers.at(tab_idx);
if (!tab->getVisible())
@@ -821,8 +832,8 @@ void LLTeleportHistoryPanel::replaceItem(S32 removed_index)
std::vector<LLPanel*> items;
fv->getItems(items);
- S32 items_cnt = items.size();
- for (S32 n = 0; n < items_cnt; ++n)
+ auto items_cnt = items.size();
+ for (size_t n = 0; n < items_cnt; ++n)
{
LLTeleportHistoryFlatItem *item = (LLTeleportHistoryFlatItem*) items[n];
@@ -857,9 +868,9 @@ void LLTeleportHistoryPanel::showTeleportHistory()
mTeleportHistory = LLTeleportHistoryStorage::getInstance();
}
- mCurrentItem = mTeleportHistory->getItems().size() - 1;
+ mCurrentItem = static_cast<S32>(mTeleportHistory->getItems().size()) - 1;
- for (S32 n = mItemContainers.size() - 1; n >= 0; --n)
+ for (S32 n = static_cast<S32>(mItemContainers.size()) - 1; n >= 0; --n)
{
LLAccordionCtrlTab* tab = mItemContainers.at(n);
if (tab)
@@ -884,9 +895,9 @@ void LLTeleportHistoryPanel::handleItemSelect(LLFlatListView* selected)
if (item)
mLastSelectedItemIndex = item->getIndex();
- S32 tabs_cnt = mItemContainers.size();
+ auto tabs_cnt = mItemContainers.size();
- for (S32 n = 0; n < tabs_cnt; n++)
+ for (size_t n = 0; n < tabs_cnt; n++)
{
LLAccordionCtrlTab* tab = mItemContainers.at(n);
@@ -939,18 +950,17 @@ void LLTeleportHistoryPanel::onAccordionTabRightClick(LLView *view, S32 x, S32 y
// set up the callbacks for all of the avatar menu items
// (N.B. callbacks don't take const refs as mID is local scope)
- LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
-
- registrar.add("TeleportHistory.TabOpen", boost::bind(&LLTeleportHistoryPanel::onAccordionTabOpen, this, tab));
- registrar.add("TeleportHistory.TabClose", boost::bind(&LLTeleportHistoryPanel::onAccordionTabClose, this, tab));
+ ScopedRegistrarHelper registrar;
+ registrar.add("TeleportHistory.TabOpen", boost::bind(&LLTeleportHistoryPanel::onAccordionTabOpen, this, tab));
+ registrar.add("TeleportHistory.TabClose", boost::bind(&LLTeleportHistoryPanel::onAccordionTabClose, this, tab));
// create the context menu from the XUI
llassert(LLMenuGL::sMenuContainer != NULL);
mAccordionTabMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>(
"menu_teleport_history_tab.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance());
- mAccordionTabMenu->setItemVisible("TabOpen", !tab->isExpanded() ? true : false);
- mAccordionTabMenu->setItemVisible("TabClose", tab->isExpanded() ? true : false);
+ mAccordionTabMenu->setItemVisible("TabOpen", !tab->isExpanded());
+ mAccordionTabMenu->setItemVisible("TabClose", tab->isExpanded());
mAccordionTabMenu->show(x, y);
LLMenuGL::showPopup(tab, mAccordionTabMenu, x, y);
@@ -1001,7 +1011,7 @@ LLFlatListView* LLTeleportHistoryPanel::getFlatListViewFromTab(LLAccordionCtrlTa
void LLTeleportHistoryPanel::gotSLURLCallback(const std::string& slurl)
{
- LLClipboard::instance().copyToClipboard(utf8str_to_wstring(slurl), 0, slurl.size());
+ LLClipboard::instance().copyToClipboard(utf8str_to_wstring(slurl), 0, static_cast<S32>(slurl.size()));
LLSD args;
args["SLURL"] = slurl;
@@ -1015,9 +1025,9 @@ void LLTeleportHistoryPanel::onGearMenuAction(const LLSD& userdata)
if ("expand_all" == command_name)
{
- S32 tabs_cnt = mItemContainers.size();
+ auto tabs_cnt = mItemContainers.size();
- for (S32 n = 0; n < tabs_cnt; n++)
+ for (size_t n = 0; n < tabs_cnt; n++)
{
mItemContainers.at(n)->setDisplayChildren(true);
}
@@ -1025,9 +1035,9 @@ void LLTeleportHistoryPanel::onGearMenuAction(const LLSD& userdata)
}
else if ("collapse_all" == command_name)
{
- S32 tabs_cnt = mItemContainers.size();
+ auto tabs_cnt = mItemContainers.size();
- for (S32 n = 0; n < tabs_cnt; n++)
+ for (size_t n = 0; n < tabs_cnt; n++)
{
mItemContainers.at(n)->setDisplayChildren(false);
}
@@ -1082,12 +1092,12 @@ bool LLTeleportHistoryPanel::isActionEnabled(const LLSD& userdata) const
if (command_name == "collapse_all"
|| command_name == "expand_all")
{
- S32 tabs_cnt = mItemContainers.size();
+ auto tabs_cnt = mItemContainers.size();
bool has_expanded_tabs = false;
bool has_collapsed_tabs = false;
- for (S32 n = 0; n < tabs_cnt; n++)
+ for (size_t n = 0; n < tabs_cnt; n++)
{
LLAccordionCtrlTab* tab = mItemContainers.at(n);
if (!tab->getVisible())