diff options
author | Mnikolenko ProductEngine <mnikolenko@productengine.com> | 2014-02-18 15:29:35 +0200 |
---|---|---|
committer | Mnikolenko ProductEngine <mnikolenko@productengine.com> | 2014-02-18 15:29:35 +0200 |
commit | ee9973ac8e8cfeb9a6600da0f422e5d9c21ad772 (patch) | |
tree | c155410cc9a8987811fa86d206f457fe6ded9a07 /indra/newview | |
parent | a347267cf1c55a3bd57d30117b8aa834623e1d61 (diff) |
MAINT-3720 Timestamp are added to Places->Teleport History. It is only shown for today and yesterday.
Diffstat (limited to 'indra/newview')
-rwxr-xr-x | indra/newview/llpanelteleporthistory.cpp | 62 | ||||
-rwxr-xr-x | indra/newview/skins/default/xui/en/panel_teleport_history_item.xml | 15 |
2 files changed, 74 insertions, 3 deletions
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp index 9c380f63bd..be9b095644 100755 --- a/indra/newview/llpanelteleporthistory.cpp +++ b/indra/newview/llpanelteleporthistory.cpp @@ -45,6 +45,7 @@ #include "llviewermenu.h" #include "lllandmarkactions.h" #include "llclipboard.h" +#include "lltrans.h" // Maximum number of items that can be added to a list in one pass. // Used to limit time spent for items list update per frame. @@ -55,7 +56,8 @@ static const std::string COLLAPSED_BY_USER = "collapsed_by_user"; class LLTeleportHistoryFlatItem : public LLPanel { public: - LLTeleportHistoryFlatItem(S32 index, LLTeleportHistoryPanel::ContextMenu *context_menu, const std::string ®ion_name, const std::string &hl); + LLTeleportHistoryFlatItem(S32 index, LLTeleportHistoryPanel::ContextMenu *context_menu, const std::string ®ion_name, + LLDate date, const std::string &hl); virtual ~LLTeleportHistoryFlatItem(); virtual BOOL postBuild(); @@ -66,8 +68,11 @@ public: void setIndex(S32 index) { mIndex = index; } const std::string& getRegionName() { return mRegionName;} void setRegionName(const std::string& name); + void setDate(LLDate date); void setHighlightedText(const std::string& text); void updateTitle(); + void updateTimestamp(); + std::string getTimestamp(); /*virtual*/ void setValue(const LLSD& value); @@ -84,12 +89,14 @@ private: LLButton* mProfileBtn; LLTextBox* mTitle; + LLTextBox* mTimeTextBox; LLTeleportHistoryPanel::ContextMenu *mContextMenu; S32 mIndex; std::string mRegionName; std::string mHighlight; + LLDate mDate; LLRootHandle<LLTeleportHistoryFlatItem> mItemHandle; }; @@ -121,11 +128,13 @@ private: //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -LLTeleportHistoryFlatItem::LLTeleportHistoryFlatItem(S32 index, LLTeleportHistoryPanel::ContextMenu *context_menu, const std::string ®ion_name, const std::string &hl) +LLTeleportHistoryFlatItem::LLTeleportHistoryFlatItem(S32 index, LLTeleportHistoryPanel::ContextMenu *context_menu, const std::string ®ion_name, + LLDate date, const std::string &hl) : LLPanel(), mIndex(index), mContextMenu(context_menu), mRegionName(region_name), + mDate(date), mHighlight(hl) { buildFromFile( "panel_teleport_history_item.xml"); @@ -140,11 +149,14 @@ BOOL LLTeleportHistoryFlatItem::postBuild() { mTitle = getChild<LLTextBox>("region"); + mTimeTextBox = getChild<LLTextBox>("timestamp"); + mProfileBtn = getChild<LLButton>("profile_btn"); mProfileBtn->setClickedCallback(boost::bind(&LLTeleportHistoryFlatItem::onProfileBtnClick, this)); updateTitle(); + updateTimestamp(); return true; } @@ -179,6 +191,38 @@ void LLTeleportHistoryFlatItem::setRegionName(const std::string& name) mRegionName = name; } +void LLTeleportHistoryFlatItem::setDate(LLDate date) +{ + mDate = date; +} + +std::string LLTeleportHistoryFlatItem::getTimestamp() +{ + const LLDate &date = mDate; + std::string timestamp = ""; + + LLDate now = LLDate::now(); + S32 now_year, now_month, now_day, now_hour, now_min, now_sec; + now.split(&now_year, &now_month, &now_day, &now_hour, &now_min, &now_sec); + + const S32 seconds_in_day = 24 * 60 * 60; + S32 seconds_today = now_hour * 60 * 60 + now_min * 60 + now_sec; + S32 time_diff = (S32) now.secondsSinceEpoch() - (S32) date.secondsSinceEpoch(); + + // 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")+"]"; + LLSD substitution; + substitution["datetime"] = (S32) date.secondsSinceEpoch(); + LLStringUtil::format(timestamp, substitution); + } + + return timestamp; + +} + void LLTeleportHistoryFlatItem::updateTitle() { static LLUIColor sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", LLColor4U(255, 255, 255)); @@ -190,6 +234,17 @@ void LLTeleportHistoryFlatItem::updateTitle() mHighlight); } +void LLTeleportHistoryFlatItem::updateTimestamp() +{ + static LLUIColor sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", LLColor4U(255, 255, 255)); + + LLTextUtil::textboxSetHighlightedVal( + mTimeTextBox, + LLStyle::Params().color(sFgColor), + getTimestamp(), + mHighlight); +} + void LLTeleportHistoryFlatItem::onMouseEnter(S32 x, S32 y, MASK mask) { getChildView("hovered_icon")->setVisible( true); @@ -248,9 +303,11 @@ LLTeleportHistoryFlatItemStorage::getFlatItemForPersistentItem ( { item->setIndex(cur_item_index); item->setRegionName(persistent_item.mTitle); + item->setDate(persistent_item.mDate); item->setHighlightedText(hl); item->setVisible(TRUE); item->updateTitle(); + item->updateTimestamp(); } else { @@ -264,6 +321,7 @@ LLTeleportHistoryFlatItemStorage::getFlatItemForPersistentItem ( item = new LLTeleportHistoryFlatItem(cur_item_index, context_menu, persistent_item.mTitle, + persistent_item.mDate, hl); mItems.push_back(item->getItemHandle()); } diff --git a/indra/newview/skins/default/xui/en/panel_teleport_history_item.xml b/indra/newview/skins/default/xui/en/panel_teleport_history_item.xml index c5b0be0616..26cac06648 100755 --- a/indra/newview/skins/default/xui/en/panel_teleport_history_item.xml +++ b/indra/newview/skins/default/xui/en/panel_teleport_history_item.xml @@ -47,7 +47,20 @@ text_color="White" top="4" value="..." - width="330" /> + width="290" /> + <text + follows="right" + height="20" + layout="topleft" + left_pad="5" + right="-20" + parse_urls="false" + use_ellipses="true" + name="timestamp" + text_color="White" + top="4" + value="..." + width="45" /> <button follows="right" height="20" |