diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-08-26 20:45:15 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-08-26 20:45:15 +0200 |
commit | 624b0733d0a028e374bad2199819d3a25632f30c (patch) | |
tree | 1a56bf2d26563ae301452b48a0aa24029d84e8d2 /src/urlbar/listitem.cpp | |
parent | Adding QWeakPointers for the walletbar and the previewselectorbar. (diff) | |
parent | Name cleanup in WebSnap::imagePathFromUrl with QRegExp. (diff) | |
download | rekonq-624b0733d0a028e374bad2199819d3a25632f30c.tar.xz |
Merge commit 'refs/merge-requests/191' of git://gitorious.org/rekonq/mainline into m2_191
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))); } |