DEV-50271 FIX SLURL support for non-clickable display names

revived mDisabledLink to make url replacement logic work again
meow-7.2.2
Richard Linden 2010-05-25 18:52:24 -07:00
parent d8f2e1d820
commit d539145367
6 changed files with 38 additions and 45 deletions

View File

@ -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

View File

@ -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:

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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());
}
}