summaryrefslogtreecommitdiff
path: root/src/urlbar/listitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/urlbar/listitem.cpp')
-rw-r--r--src/urlbar/listitem.cpp59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index f10cefd7..e9bb6fbb 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -139,6 +139,12 @@ KUrl ListItem::url()
}
+QString ListItem::text()
+{
+ return m_url.url();
+}
+
+
void ListItem::nextItemSubChoice()
{
//will be override
@@ -161,6 +167,7 @@ TypeIconLabel::TypeIconLabel(int type, QWidget *parent)
if (type & UrlSearchItem::Browse) hLayout->addWidget(getIcon("applications-internet"));
if (type & UrlSearchItem::Bookmark) hLayout->addWidget(getIcon("rating"));
if (type & UrlSearchItem::History) hLayout->addWidget(getIcon("view-history"));
+ if (type & UrlSearchItem::Suggestion) hLayout->addWidget(getIcon("help-hint"));
}
@@ -297,6 +304,12 @@ SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, Q
}
+QString SearchListItem::text()
+{
+ return m_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)));
@@ -390,6 +403,42 @@ void EngineBar::selectNextEngine()
// ---------------------------------------------------------------
+SuggestionListItem::SuggestionListItem(const UrlSearchItem &item, const QString &text, QWidget *parent)
+ : ListItem(item, parent)
+ , m_text(item.title)
+{
+ QHBoxLayout *hLayout = new QHBoxLayout;
+ hLayout->setSpacing(4);
+
+ QString query = item.title;
+ KService::Ptr engine = SearchEngine::fromString(query);
+ if (engine)
+ {
+ query = query.remove(0, text.indexOf(SearchEngine::delimiter()) + 1);
+ }
+ else
+ {
+ engine = qobject_cast<CompletionWidget *>(parent)->searchEngine();
+ }
+
+ m_url = SearchEngine::buildQuery(engine, query);
+
+ hLayout->addWidget(new IconLabel(SearchEngine::buildQuery(engine, ""), this));
+ hLayout->addWidget(new TextLabel(item.title, text, this));
+ hLayout->addWidget(new TypeIconLabel(item.type, this));
+
+ setLayout(hLayout);
+}
+
+
+QString SuggestionListItem::text()
+{
+ return m_text;
+}
+
+// ---------------------------------------------------------------
+
+
BrowseListItem::BrowseListItem(const UrlSearchItem &item, const QString &text, QWidget *parent)
: ListItem(item, parent)
{
@@ -427,7 +476,15 @@ ListItem *ListItemFactory::create(const UrlSearchItem &item, const QString &text
}
else
{
- newItem = new PreviewListItem(item, text, parent);
+
+ if (item.type & UrlSearchItem::Suggestion)
+ {
+ newItem = new SuggestionListItem(item, text, parent);
+ }
+ else
+ {
+ newItem = new PreviewListItem(item, text, parent);
+ }
}
}