diff options
author | Steven Bennetts <steve@lindenlab.com> | 2009-08-07 23:41:29 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2009-08-07 23:41:29 +0000 |
commit | 9828faf565d0146739495cb14270c400c9249c8d (patch) | |
tree | 65485957eb21f5829c754bcd11f3c5bdc721578f /indra/newview/lllocationhistory.cpp | |
parent | e3d84d5e88751633eac27723bc775a5ad0248906 (diff) |
Command: Merging from https://svn.aws.productengine.com/secondlife/export-from-ll/viewer-2-0/indra, revision 1245 to https://svn.aws.productengine.com/secondlife/pe/stable-1/indra, revision 1246 into P:\svn\viewer-2-0\latest\indra, ignoring ancestry
* EXT-277 - Modifications to the Location Bar Context Menu
* EXT-252 - /whisper, /shout
* EXT-254 - IM chiclet counter
* EXT-267 - 'Status' drop-down menu doesn't drop in the Side tray / Me panel
* EXT-298 - Update Places Panel Spec to reflect latest Create Landmark format
* EXT-278 - Input Field History should display human readable names
* EXT-317 - Avatar profile isn't opened in the sidetray as Profile Info panel when selecting an avatar in the search
* Changes to notification tips
* Changes to movement and camera controls
* Side Tray functionality additions and code cleanup
Diffstat (limited to 'indra/newview/lllocationhistory.cpp')
-rw-r--r-- | indra/newview/lllocationhistory.cpp | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/indra/newview/lllocationhistory.cpp b/indra/newview/lllocationhistory.cpp index 68143fd1e3..03d6953521 100644 --- a/indra/newview/lllocationhistory.cpp +++ b/indra/newview/lllocationhistory.cpp @@ -38,33 +38,58 @@ #include "llui.h" +const char LLLocationHistory::delimiter = '\t'; + LLLocationHistory::LLLocationHistory() : mFilename("typed_locations.txt") { } -void LLLocationHistory::addItem(std::string item) -{ +void LLLocationHistory::addItem(const std::string & item, const std::string & tooltip) { static LLUICachedControl<S32> max_items("LocationHistoryMaxSize", 100); - - std::vector<std::string>::iterator item_iter = std::find(mItems.begin(), mItems.end(), item); - if (item_iter != mItems.end()) { - mItems.erase(item_iter); + // check if this item doesn't duplicate any existing one + if (touchItem(item)) { + return; } mItems.push_back(item); + mToolTips[item] = tooltip; // If the vector size exceeds the maximum, purge the oldest items. - if ((S32)mItems.size() > max_items) - mItems.erase(mItems.begin(), mItems.end()-max_items); + if ((S32)mItems.size() > max_items) { + for(std::vector<std::string>::iterator i = mItems.begin(); i != mItems.end()-max_items; ++i) { + mToolTips.erase(*i); + mItems.erase(i); + } + } +} + +bool LLLocationHistory::touchItem(const std::string & item) { + bool result = false; + std::vector<std::string>::iterator item_iter = std::find(mItems.begin(), mItems.end(), item); + + // the last used item should be the first in the history + if (item_iter != mItems.end()) { + mItems.erase(item_iter); + mItems.push_back(item); + result = true; + } + + return result; } void LLLocationHistory::removeItems() { mItems.clear(); + mToolTips.clear(); } +std::string LLLocationHistory::getToolTip(const std::string & item) const { + std::map<std::string, std::string>::const_iterator i = mToolTips.find(item); + + return i != mToolTips.end() ? i->second : ""; +} bool LLLocationHistory::getMatchingItems(std::string substring, location_list_t& result) const { @@ -110,7 +135,7 @@ void LLLocationHistory::save() const } for (location_list_t::const_iterator it = mItems.begin(); it != mItems.end(); ++it) - file << (*it) << std::endl; + file << (*it) << delimiter << mToolTips.find(*it)->second << std::endl; file.close(); } @@ -129,13 +154,21 @@ void LLLocationHistory::load() return; } - // remove current entries before we load over them - mItems.clear(); + removeItems(); // add each line in the file to the list std::string line; - while (std::getline(file, line)) - addItem(line); + + while (std::getline(file, line)) { + size_t dp = line.find(delimiter); + + if (dp != std::string::npos) { + const std::string reg_name = line.substr(0, dp); + const std::string tooltip = line.substr(dp + 1, std::string::npos); + + addItem(reg_name, tooltip); + } + } file.close(); |