diff options
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/listitem.cpp | 11 | ||||
-rw-r--r-- | src/urlbar/rsswidget.cpp | 5 | ||||
-rw-r--r-- | src/urlbar/urlresolver.cpp | 40 | ||||
-rw-r--r-- | src/urlbar/urlresolver.h | 13 |
4 files changed, 48 insertions, 21 deletions
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index f91840d2..5254c7dc 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -220,7 +220,16 @@ PreviewListItem::PreviewListItem(const UrlSearchItem &item, const QString &text, QVBoxLayout *vLayout = new QVBoxLayout; vLayout->setMargin(0); - vLayout->addWidget(new TextLabel(item.title, text, this)); + + QString title = item.title; + if (title.isEmpty()) + { + title = item.url.url(); + title = title.remove("http://"); + title.truncate(title.indexOf("/")); + } + + vLayout->addWidget(new TextLabel(title, text, this)); vLayout->addWidget(new TextLabel("<i>" + item.url.url() + "</i>", text, this)); hLayout->addLayout(vLayout); diff --git a/src/urlbar/rsswidget.cpp b/src/urlbar/rsswidget.cpp index 07b45853..6cd63b95 100644 --- a/src/urlbar/rsswidget.cpp +++ b/src/urlbar/rsswidget.cpp @@ -115,9 +115,12 @@ RSSWidget::~RSSWidget() void RSSWidget::showAt(const QPoint &pos) { + adjustSize(); + QPoint p; - p.setX(pos.x() - 200); + p.setX(pos.x() - width()); p.setY(pos.y() + 10); + move(p); show(); } diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index 21e3fe9c..07b40bac 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -141,12 +141,23 @@ UrlSearchList UrlResolver::orderedSearchItems() int checkPoint = 9 - firstResults; UrlSearchList historyList = historyResolution(); + UrlSearchItem privileged = privilegedItem(&historyList); int historyResults = historyList.count(); + + UrlSearchList bookmarksList = bookmarksResolution(); + if (privileged.type == UrlSearchItem::Undefined) + { + privileged = privilegedItem(&bookmarksList); + } + + if (privileged.type != UrlSearchItem::Undefined) + { + list.insert(0,privileged); + } - UrlSearchList bookmarksList = bookmarksResolution(); - int bookmarkResults = bookmarksList.count(); + int bookmarksResults = bookmarksList.count(); - if (historyResults + bookmarkResults > checkPoint) + if (historyResults + bookmarksResults > checkPoint) { historyList = historyList.mid(0, 3); bookmarksList = bookmarksList.mid(0, 3); @@ -178,8 +189,6 @@ UrlSearchList UrlResolver::orderedSearchItems() list << i; } - list = placeTypedDomaineNameOnTop(list); - return list; } @@ -246,22 +255,19 @@ UrlSearchList UrlResolver::bookmarksResolution() } -UrlSearchList UrlResolver::placeTypedDomaineNameOnTop(UrlSearchList list) +UrlSearchItem UrlResolver::privilegedItem(UrlSearchList* list) { - int i = 0; - bool found = false; - - while(i<list.count() && !found) + int i=0; + while(i<list->count()) { - UrlSearchItem item = list.at(i); - if (item.url.url().contains("."+_typedString+".") || item.url.url().contains("/"+_typedString+".")) + UrlSearchItem item = list->at(i); + kDebug() << item.url.host(); + if (item.url.host().contains( _typedString + QL1C('.') ) ) { - list.removeAt(i); - list.insert(0,item); - found = true; + list->removeAt(i); + return item; } i++; } - - return list; + return UrlSearchItem(); } diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h index 0c7df8c8..2249ea32 100644 --- a/src/urlbar/urlresolver.h +++ b/src/urlbar/urlresolver.h @@ -45,6 +45,7 @@ public: enum types { + Undefined = 0x00000000, Search = 0x00000001, Browse = 0x00000010, History = 0x00000100, @@ -54,7 +55,15 @@ public: int type; KUrl url; QString title; - + + UrlSearchItem(const UrlSearchItem &item) + : type(item.type), url(item.url), title(item.title) + {}; + + UrlSearchItem() + : type(UrlSearchItem::Undefined), url(KUrl()), title("") + {}; + UrlSearchItem(const int &_type, const KUrl &_url, const QString &_title = QString()) : type(_type), url(_url), title(_title) {}; @@ -82,7 +91,7 @@ private: UrlSearchList historyResolution(); UrlSearchList qurlFromUserInputResolution(); UrlSearchList bookmarksResolution(); - UrlSearchList placeTypedDomaineNameOnTop(UrlSearchList list); + UrlSearchItem privilegedItem(UrlSearchList* list); static QRegExp _browseRegexp; }; |