diff options
author | Pierre Rossi <pierre.rossi@nokia.com> | 2010-08-24 13:06:02 +0200 |
---|---|---|
committer | Pierre Rossi <pierre.rossi@nokia.com> | 2010-08-25 11:02:57 +0200 |
commit | 8021b32b5288de901ec2c1defb3712211598925a (patch) | |
tree | d7810d9e3c205b5ae8520d07bce6507112e4ef57 /src/urlbar/listitem.cpp | |
parent | SVN_SILENT made messages (.desktop file) (diff) | |
download | rekonq-8021b32b5288de901ec2c1defb3712211598925a.tar.xz |
Awesome bar: support for multiple word search.
Also support searches starting by i (without messing with the <i> for urls)
and page titles with characters such as '<' or '>'.
Diffstat (limited to 'src/urlbar/listitem.cpp')
-rw-r--r-- | src/urlbar/listitem.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index e9bb6fbb..5bd2253f 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -200,8 +200,17 @@ TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget : QLabel(parent) { QString t = text; - if (!textToPointOut.isEmpty()) - t = t.replace(QRegExp('(' + textToPointOut + ')', Qt::CaseInsensitive), "<b>\\1</b>"); + const bool wasItalic = t.startsWith("<i>"); + if (wasItalic) + t.remove(QRegExp("<[/ib]*>")); + t = Qt::escape(t); + QStringList words = textToPointOut.split(" "); + foreach (const QString &wordToPointOut, words) { + if (!wordToPointOut.isEmpty()) + t.replace(QRegExp('(' + wordToPointOut + ')', Qt::CaseInsensitive), "<b>\\1</b>"); + } + if (wasItalic) + t = QL1S("<i>") + t + QL1S("</i>"); setText(t); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); @@ -286,7 +295,7 @@ SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, Q m_url = SearchEngine::buildQuery(engine, query); m_iconLabel = new IconLabel("edit-find", this); //TODO: get the default engine icon (will be easy in KDE SC 4.5) - m_titleLabel = new TextLabel(searchItemTitle(engine->name(), query), QString(), this); + m_titleLabel = new TextLabel(searchItemTitle(engine->name(), query), query, this); m_engineBar = new EngineBar(engine, parent); QHBoxLayout *hLayout = new QHBoxLayout; @@ -312,7 +321,7 @@ QString SearchListItem::text() QString SearchListItem::searchItemTitle(QString engine, QString text) { - return QString(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for <b>%2</b>", engine, Qt::escape(text))); + return QString(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for %2", engine, Qt::escape(text))); } |