diff options
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/completionwidget.cpp | 2 | ||||
-rw-r--r-- | src/urlbar/listitem.cpp | 30 | ||||
-rw-r--r-- | src/urlbar/listitem.h | 12 | ||||
-rw-r--r-- | src/urlbar/urlresolver.cpp | 21 | ||||
-rw-r--r-- | src/urlbar/urlresolver.h | 4 |
5 files changed, 62 insertions, 7 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp index b77e2d7c..8e72b26b 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -34,7 +34,7 @@ // Local Includes #include "application.h" #include "urlresolver.h" -#include "searchengine.h" +#include "search/searchengine.h" #include "urlbar.h" // KDE Includes diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index f10cefd7..c9946257 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -36,7 +36,7 @@ #include "application.h" #include "websnap.h" #include "completionwidget.h" -#include "searchengine.h" +#include "search/searchengine.h" // KDE Includes #include <KIcon> @@ -161,6 +161,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")); } @@ -390,6 +391,23 @@ void EngineBar::selectNextEngine() // --------------------------------------------------------------- +SuggestionListItem::SuggestionListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) + : ListItem(item, parent) +{ + QHBoxLayout *hLayout = new QHBoxLayout; + hLayout->setSpacing(4); + + hLayout->addWidget(new IconLabel(item.url, this)); + hLayout->addWidget(new TextLabel(item.title, text, this)); + hLayout->addWidget(new TypeIconLabel(item.type, this)); + + setLayout(hLayout); +} + + +// --------------------------------------------------------------- + + BrowseListItem::BrowseListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) : ListItem(item, parent) { @@ -427,7 +445,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); + } } } diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h index dcb4f76d..0e1a7ad5 100644 --- a/src/urlbar/listitem.h +++ b/src/urlbar/listitem.h @@ -174,6 +174,18 @@ private: // ------------------------------------------------------------------------- +class SuggestionListItem : public ListItem +{ + Q_OBJECT + +public: + SuggestionListItem(const UrlSearchItem &item, const QString &text, QWidget *parent = 0); +}; + + +// ------------------------------------------------------------------------- + + class PreviewListItem : public ListItem { Q_OBJECT diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index f0fd257b..157e26a2 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -31,7 +31,7 @@ #include "application.h" #include "historymanager.h" #include "bookmarksmanager.h" -#include "searchengine.h" +#include "search/searchengine.h" // KDE Includes #include <KUriFilter> @@ -243,11 +243,14 @@ UrlSearchList UrlResolver::orderedSearchItems() availableEntries -= commonList.count(); } + + UrlSearchList suggestionsList = suggestionResolution(); historyResults = historyList.count(); bookmarksResults = bookmarksList.count(); commonResutls = commonList.count(); - + //TODO: count suggestions entries + //now fill the list to MAX_ELEMENTS if(availableEntries > 0) { @@ -275,7 +278,7 @@ UrlSearchList UrlResolver::orderedSearchItems() } } - list = list + historyList + commonList + bookmarksList; + list = list + historyList + commonList + bookmarksList + suggestionsList; qWarning() << "orderedSearchItems leave: " << " elapsed: " << myTime.elapsed(); return list; @@ -343,6 +346,18 @@ UrlSearchList UrlResolver::bookmarksResolution() } +// STEP 4 = suggestion completion +UrlSearchList UrlResolver::suggestionResolution() +{ + + UrlSearchList list; + UrlSearchItem gItem(UrlSearchItem::Suggestion, "a", "a"); + list << gItem; + + return list; +} + + UrlSearchItem UrlResolver::privilegedItem(UrlSearchList* list) { UrlSearchItem item; diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h index c79ce184..d41e3f1a 100644 --- a/src/urlbar/urlresolver.h +++ b/src/urlbar/urlresolver.h @@ -50,6 +50,7 @@ public: Browse = 0x00000010, History = 0x00000100, Bookmark = 0x00001000, + Suggestion = 0x00010000, }; int type; @@ -108,7 +109,8 @@ private: UrlSearchList qurlFromUserInputResolution(); UrlSearchList bookmarksResolution(); UrlSearchItem privilegedItem(UrlSearchList* list); - + UrlSearchList suggestionResolution(); + static QRegExp _browseRegexp; static QRegExp _searchEnginesRegexp; }; |