diff options
author | Richard Linden <none@none> | 2010-05-25 18:52:24 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2010-05-25 18:52:24 -0700 |
commit | d539145367d74c0881bcf47daefaca4820f04c72 (patch) | |
tree | 312044bd5858c61de403fcf3cde977cf300a1b06 | |
parent | d8f2e1d820e717f267375773407110bec1e9dae2 (diff) |
DEV-50271 FIX SLURL support for non-clickable display names
revived mDisabledLink to make url replacement logic work again
-rw-r--r-- | indra/llui/llurlentry.cpp | 28 | ||||
-rw-r--r-- | indra/llui/llurlentry.h | 6 | ||||
-rw-r--r-- | indra/llui/llurlmatch.cpp | 7 | ||||
-rw-r--r-- | indra/llui/llurlmatch.h | 6 | ||||
-rw-r--r-- | indra/llui/llurlregistry.cpp | 6 | ||||
-rw-r--r-- | indra/llui/tests/llurlmatch_test.cpp | 30 |
6 files changed, 38 insertions, 45 deletions
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 866c228a12..60566f457d 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -49,6 +49,7 @@ std::string localize_slapp_label(const std::string& url, const std::string& full LLUrlEntryBase::LLUrlEntryBase() +: mDisabledLink(false) {} LLUrlEntryBase::~LLUrlEntryBase() @@ -493,24 +494,7 @@ std::string LLUrlEntryAgent::getIcon(const std::string &url) // LLUrlEntryAgentName::LLUrlEntryAgentName() { -} - -// virtual -void LLUrlEntryAgentName::callObservers(const std::string &id, - const std::string &label, - const std::string &icon) -{ - // notify all callbacks waiting on the given uuid - std::multimap<std::string, LLUrlEntryObserver>::iterator it; - for (it = mObservers.find(id); it != mObservers.end();) - { - // call the callback - give it the new label - LLUrlEntryObserver &observer = it->second; - (*observer.signal)(observer.url, label, icon); - // then remove the signal - we only need to call it once - delete observer.signal; - mObservers.erase(it++); - } + mDisabledLink = true; } void LLUrlEntryAgentName::onAvatarNameCache(const LLUUID& id, @@ -557,13 +541,9 @@ std::string LLUrlEntryAgentName::getLabel(const std::string &url, const LLUrlLab } } -std::string LLUrlEntryAgentName::getUrl(const std::string &url) const -{ - return LLStringUtil::null; -} - LLStyle::Params LLUrlEntryAgentName::getStyle() const { + // don't override default colors return LLStyle::Params(); } @@ -969,6 +949,7 @@ LLUrlEntryNoLink::LLUrlEntryNoLink() { mPattern = boost::regex("<nolink>[^<]*</nolink>", boost::regex::perl|boost::regex::icase); + mDisabledLink = true; } std::string LLUrlEntryNoLink::getUrl(const std::string &url) const @@ -995,6 +976,7 @@ LLUrlEntryIcon::LLUrlEntryIcon() { mPattern = boost::regex("<icon\\s*>\\s*([^<]*)?\\s*</icon\\s*>", boost::regex::perl|boost::regex::icase); + mDisabledLink = true; } std::string LLUrlEntryIcon::getUrl(const std::string &url) const diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index cd93d1ac41..ca4562cee0 100644 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -95,6 +95,9 @@ public: /// Return the name of a SL location described by this Url, if any virtual std::string getLocation(const std::string &url) const { return ""; } + /// is this a match for a URL that should not be hyperlinked? + bool isLinkDisabled() const { return mDisabledLink; } + protected: std::string getIDStringFromUrl(const std::string &url) const; std::string escapeUrl(const std::string &url) const; @@ -114,6 +117,7 @@ protected: std::string mMenuName; std::string mTooltip; std::multimap<std::string, LLUrlEntryObserver> mObservers; + bool mDisabledLink; }; /// @@ -186,10 +190,8 @@ class LLUrlEntryAgentName : public LLUrlEntryBase public: LLUrlEntryAgentName(); /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); - /*virtual*/ std::string getUrl(const std::string &string) const; /*virtual*/ LLStyle::Params getStyle() const; protected: - /*virtual*/ void callObservers(const std::string &id, const std::string &label, const std::string& icon); // override this to pull out relevant name fields virtual std::string getName(const LLAvatarName& avatar_name) = 0; private: diff --git a/indra/llui/llurlmatch.cpp b/indra/llui/llurlmatch.cpp index 51fca6d7c0..dcfdd70b42 100644 --- a/indra/llui/llurlmatch.cpp +++ b/indra/llui/llurlmatch.cpp @@ -42,14 +42,16 @@ LLUrlMatch::LLUrlMatch() : mTooltip(""), mIcon(""), mMenuName(""), - mLocation("") + mLocation(""), + mDisabledLink(false) { } void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, const std::string &label, const std::string &tooltip, const std::string &icon, const LLStyle::Params& style, - const std::string &menu, const std::string &location) + const std::string &menu, const std::string &location, + bool disabled_link) { mStart = start; mEnd = end; @@ -61,4 +63,5 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, mStyle.link_href = url; mMenuName = menu; mLocation = location; + mDisabledLink = disabled_link; } diff --git a/indra/llui/llurlmatch.h b/indra/llui/llurlmatch.h index 43bd9da14a..92a87c3d4c 100644 --- a/indra/llui/llurlmatch.h +++ b/indra/llui/llurlmatch.h @@ -83,11 +83,14 @@ public: /// return the SL location that this Url describes, or "" if none. std::string getLocation() const { return mLocation; } + /// is this a match for a URL that should not be hyperlinked? + bool isLinkDisabled() const { return mDisabledLink; } + /// Change the contents of this match object (used by LLUrlRegistry) void setValues(U32 start, U32 end, const std::string &url, const std::string &label, const std::string &tooltip, const std::string &icon, const LLStyle::Params& style, const std::string &menu, - const std::string &location); + const std::string &location, bool disabled_link); private: U32 mStart; @@ -99,6 +102,7 @@ private: std::string mMenuName; std::string mLocation; LLStyle::Params mStyle; + bool mDisabledLink; }; #endif diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp index f119233f8f..f61603545f 100644 --- a/indra/llui/llurlregistry.cpp +++ b/indra/llui/llurlregistry.cpp @@ -192,7 +192,8 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL match_entry->getIcon(url), match_entry->getStyle(), match_entry->getMenuName(), - match_entry->getLocation(url)); + match_entry->getLocation(url), + match_entry->isLinkDisabled()); return true; } @@ -225,7 +226,8 @@ bool LLUrlRegistry::findUrl(const LLWString &text, LLUrlMatch &match, const LLUr match.getIcon(), match.getStyle(), match.getMenuName(), - match.getLocation()); + match.getLocation(), + match.isLinkDisabled()); return true; } return false; diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp index 85318196e0..ab5770dbf2 100644 --- a/indra/llui/tests/llurlmatch_test.cpp +++ b/indra/llui/tests/llurlmatch_test.cpp @@ -154,7 +154,7 @@ namespace tut LLUrlMatch match; ensure("empty()", match.empty()); - match.setValues(0, 1, "http://secondlife.com", "Second Life", "", "", LLStyle::Params(), "", ""); + match.setValues(0, 1, "http://secondlife.com", "Second Life", "", "", LLStyle::Params(), "", "", false); ensure("! empty()", ! match.empty()); } @@ -167,7 +167,7 @@ namespace tut LLUrlMatch match; ensure_equals("getStart() == 0", match.getStart(), 0); - match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", ""); + match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false); ensure_equals("getStart() == 10", match.getStart(), 10); } @@ -180,7 +180,7 @@ namespace tut LLUrlMatch match; ensure_equals("getEnd() == 0", match.getEnd(), 0); - match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", ""); + match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false); ensure_equals("getEnd() == 20", match.getEnd(), 20); } @@ -193,10 +193,10 @@ namespace tut LLUrlMatch match; ensure_equals("getUrl() == ''", match.getUrl(), ""); - match.setValues(10, 20, "http://slurl.com/", "", "", "", LLStyle::Params(), "", ""); + match.setValues(10, 20, "http://slurl.com/", "", "", "", LLStyle::Params(), "", "", false); ensure_equals("getUrl() == 'http://slurl.com/'", match.getUrl(), "http://slurl.com/"); - match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", ""); + match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false); ensure_equals("getUrl() == '' (2)", match.getUrl(), ""); } @@ -209,10 +209,10 @@ namespace tut LLUrlMatch match; ensure_equals("getLabel() == ''", match.getLabel(), ""); - match.setValues(10, 20, "", "Label", "", "", LLStyle::Params(), "", ""); + match.setValues(10, 20, "", "Label", "", "", LLStyle::Params(), "", "", false); ensure_equals("getLabel() == 'Label'", match.getLabel(), "Label"); - match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", ""); + match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false); ensure_equals("getLabel() == '' (2)", match.getLabel(), ""); } @@ -225,10 +225,10 @@ namespace tut LLUrlMatch match; ensure_equals("getTooltip() == ''", match.getTooltip(), ""); - match.setValues(10, 20, "", "", "Info", "", LLStyle::Params(), "", ""); + match.setValues(10, 20, "", "", "Info", "", LLStyle::Params(), "", "", false); ensure_equals("getTooltip() == 'Info'", match.getTooltip(), "Info"); - match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", ""); + match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false); ensure_equals("getTooltip() == '' (2)", match.getTooltip(), ""); } @@ -241,10 +241,10 @@ namespace tut LLUrlMatch match; ensure_equals("getIcon() == ''", match.getIcon(), ""); - match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "", ""); + match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "", "", false); ensure_equals("getIcon() == 'Icon'", match.getIcon(), "Icon"); - match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", ""); + match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false); ensure_equals("getIcon() == '' (2)", match.getIcon(), ""); } @@ -257,10 +257,10 @@ namespace tut LLUrlMatch match; ensure("getMenuName() empty", match.getMenuName().empty()); - match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", ""); + match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "", false); ensure_equals("getMenuName() == \"xui_file.xml\"", match.getMenuName(), "xui_file.xml"); - match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", ""); + match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false); ensure("getMenuName() empty (2)", match.getMenuName().empty()); } @@ -273,10 +273,10 @@ namespace tut LLUrlMatch match; ensure("getLocation() empty", match.getLocation().empty()); - match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "Paris"); + match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "Paris", false); ensure_equals("getLocation() == \"Paris\"", match.getLocation(), "Paris"); - match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", ""); + match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false); ensure("getLocation() empty (2)", match.getLocation().empty()); } } |