summaryrefslogtreecommitdiff
path: root/src/urlbar/urlresolver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/urlbar/urlresolver.cpp')
-rw-r--r--src/urlbar/urlresolver.cpp138
1 files changed, 12 insertions, 126 deletions
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
index d457e1fb..50f1692f 100644
--- a/src/urlbar/urlresolver.cpp
+++ b/src/urlbar/urlresolver.cpp
@@ -162,7 +162,7 @@ UrlSearchList UrlResolver::orderedSearchItems()
UrlSearchList commonList;
int commonResutls = 0;
-
+
//prefer items which are history items als well bookmarks item
//if there are more than 1000 bookmark results, the performance impact is noticeable
if(bookmarksResults < 1000)
@@ -300,16 +300,23 @@ UrlSearchList UrlResolver::webSearchesResolution()
// STEP 3 = history completion
UrlSearchList UrlResolver::historyResolution()
{
- AwesomeUrlCompletion *historyCompletion = Application::historyManager()->completionObject();
- return historyCompletion->substringCompletion(_typedString);
+ QList<HistoryHashItem> mostVisited = Application::historyManager()->findMostVisited(_typedString);
+ UrlSearchList list;
+ foreach (HistoryHashItem i, mostVisited)
+ {
+ UrlSearchItem gItem(UrlSearchItem::History, i.url, i.title);
+ list << gItem;
+ }
+ return list;
}
// STEP 4 = bookmarks completion
UrlSearchList UrlResolver::bookmarksResolution()
{
- AwesomeUrlCompletion *bookmarkCompletion = Application::bookmarkProvider()->completionObject();
- return bookmarkCompletion->substringCompletion(_typedString);
+ UrlSearchList list;
+ //AwesomeUrlCompletion *bookmarkCompletion = Application::bookmarkProvider()->completionObject();
+ return list;
}
@@ -333,124 +340,3 @@ UrlSearchItem UrlResolver::privilegedItem(UrlSearchList* list)
}
return UrlSearchItem();
}
-
-// ------------------------------------------------------------------------------------------------------
-
-
-AwesomeUrlCompletion::AwesomeUrlCompletion()
-{
- m_resetCompletion = true;
-}
-
-
-AwesomeUrlCompletion::~AwesomeUrlCompletion()
-{
-
-}
-
-
-void AwesomeUrlCompletion::addItem(const UrlSearchItem& itemToAdd)
-{
- bool match = false;
- QTime myTime;
- myTime.start();
- for(int i = 0; i < m_items.count(); i++)
- {
- //check if item is already in list; the items are equal if the url and the title are equal
- if(m_items[i] == itemToAdd)
- {
- match = true;
- //TODO: check what to do if comment or bookmarkPath are different
- if(m_items[i] < itemToAdd)
- {
- m_items[i].visitDateTime = itemToAdd.visitDateTime;
- }
- m_items[i].visitCount += itemToAdd.visitCount;
- }
- }
- if(!match)
- {
- m_items.append(itemToAdd);
- }
- m_resetCompletion = true;
-}
-
-
-void AwesomeUrlCompletion::removeItem(const UrlSearchItem& item)
-{
- m_resetCompletion = m_items.removeOne(item);
-}
-
-
-void AwesomeUrlCompletion::setOrder(KCompletion::CompOrder)
-{
- //TODO
-}
-
-
-void AwesomeUrlCompletion::updateTitle(const UrlSearchItem& item, const QString& newTitle)
-{
- foreach(UrlSearchItem i, m_items)
- {
- if(i == item)
- {
- i.title = newTitle;
- }
- }
- m_resetCompletion = true;
-}
-
-
-void AwesomeUrlCompletion::clear()
-{
- m_items.clear();
- m_resetCompletion = true;
-}
-
-
-UrlSearchList AwesomeUrlCompletion::substringCompletion(const QString& completionString)
-{
- UrlSearchList* searchList;
- UrlSearchList tempList;
-
- if(!m_resetCompletion)
- {
- if(completionString.length() <= 1)
- {
- m_resetCompletion = true;
- }
- if(!m_resetCompletion && completionString.length() < m_lastCompletionString.length())
- {
- m_resetCompletion = true;
- }
- if(!m_resetCompletion && !completionString.startsWith(m_lastCompletionString, Qt::CaseInsensitive))
- {
- m_resetCompletion = true;
- }
- }
-
- if(m_resetCompletion)
- {
- searchList = &m_items;
- m_resetCompletion = false;
- }
- else
- {
- searchList = &m_filteredItems;
- }
-
- Q_FOREACH(const UrlSearchItem &i, *searchList)
- {
- //TODO: split string and also search for each word if the are more than one word separated with space
- if( i.url.contains(completionString, Qt::CaseInsensitive)
- || i.title.contains(completionString, Qt::CaseInsensitive)
- || i.description.contains(completionString, Qt::CaseInsensitive)
- )
- {
- tempList.append(i);
- }
- }
- m_lastCompletionString = completionString;
- m_filteredItems = tempList;
- return m_filteredItems;
-}