summaryrefslogtreecommitdiff
path: root/src/urlbar
diff options
context:
space:
mode:
Diffstat (limited to 'src/urlbar')
-rw-r--r--src/urlbar/urlresolver.cpp138
-rw-r--r--src/urlbar/urlresolver.h50
2 files changed, 14 insertions, 174 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;
-}
diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h
index 83228140..0ba93921 100644
--- a/src/urlbar/urlresolver.h
+++ b/src/urlbar/urlresolver.h
@@ -33,14 +33,11 @@
// KDE Includes
#include <KUrl>
-#include <KCompletion>
+
// Qt Includes
#include <QString>
#include <QList>
-#include <QDateTime>
-
-class AwesomeUrlCompletion;
class UrlSearchItem
{
@@ -58,25 +55,19 @@ public:
int type;
QString url;
QString title;
- QDateTime visitDateTime;
- int visitCount;
QString description;
QString bookmarkPath;
UrlSearchItem(const UrlSearchItem &item) : type(item.type),
url(item.url),
title(item.title),
- visitDateTime(item.visitDateTime),
- visitCount(item.visitCount),
description(item.description),
bookmarkPath(item.bookmarkPath)
{};
-
+
UrlSearchItem() : type(UrlSearchItem::Undefined),
url(QString()),
title(QString()),
- visitDateTime(QDateTime()),
- visitCount(0),
description(QString()),
bookmarkPath(QString())
{};
@@ -84,16 +75,12 @@ public:
UrlSearchItem(const int &_type,
const QString &_url,
const QString &_title = QString(),
- const QDateTime &visitDateTime = QDateTime(),
- const int &visitCount = 0,
const QString &description = QString(),
const QString &bookmarkPath = QString()
)
: type(_type),
url(_url),
title(_title),
- visitDateTime(visitDateTime),
- visitCount(visitCount),
description(description),
bookmarkPath(bookmarkPath)
{};
@@ -102,16 +89,6 @@ public:
{
return i.url == url;//TODO && i.title == title;
}
-
- inline bool operator <(const UrlSearchItem &i) const
- {
- return visitDateTime < i.visitDateTime;
- }
-
- inline bool operator >(const UrlSearchItem &i) const
- {
- return visitDateTime > i.visitDateTime;
- }
};
typedef QList <UrlSearchItem> UrlSearchList;
@@ -141,27 +118,4 @@ private:
// ------------------------------------------------------------------------------
-
-/**
- * This class represents all searchable item for the awesomebar.
- */
-class AwesomeUrlCompletion// : public KCompletion
-{
-public:
- AwesomeUrlCompletion();
- ~AwesomeUrlCompletion();
- void addItem(const UrlSearchItem& item);
- void removeItem(const UrlSearchItem& item);
- void setOrder(KCompletion::CompOrder);
- void updateTitle(const UrlSearchItem& item, const QString& newTitle);
- void clear();
- UrlSearchList substringCompletion(const QString& completionString);
-
-private:
- UrlSearchList m_items;
- UrlSearchList m_filteredItems;
- bool m_resetCompletion;
- QString m_lastCompletionString;
-};
-
#endif // URL_RESOLVER_H