summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/bookmarksmanager.cpp50
-rw-r--r--src/bookmarks/bookmarksmanager.h4
-rw-r--r--src/urlbar/urlresolver.cpp51
-rw-r--r--src/urlbar/urlresolver.h1
4 files changed, 93 insertions, 13 deletions
diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp
index 89e39ef8..9c3201e6 100644
--- a/src/bookmarks/bookmarksmanager.cpp
+++ b/src/bookmarks/bookmarksmanager.cpp
@@ -294,7 +294,7 @@ KAction *BookmarkProvider::fillBookmarkBar(const KBookmark &bookmark)
}
else
{
- m_completion->addItem(bookmark.url().path());
+ m_completion->addItem(bookmark.url().url());
return new KBookmarkAction(bookmark, m_owner, this);
}
}
@@ -309,3 +309,51 @@ KCompletion *BookmarkProvider::completionObject() const
{
return m_completion;
}
+
+
+
+
+
+QString BookmarkProvider::titleForBookmarkUrl(QString url)
+{
+ QString title = "";
+ KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup();
+ if (bookGroup.isNull())
+ {
+ return title;
+ }
+
+ KBookmark bookmark = bookGroup.first();
+ while (!bookmark.isNull() && title.isEmpty())
+ {
+ title = titleForBookmarkUrl(bookmark, url);
+ bookmark = bookGroup.next(bookmark);
+ }
+
+ return title;
+}
+
+
+QString BookmarkProvider::titleForBookmarkUrl(const KBookmark &bookmark, QString url)
+{
+ QString title = "";
+ if (bookmark.isGroup())
+ {
+ KBookmarkGroup group = bookmark.toGroup();
+ KBookmark bm = group.first();
+ while (!bm.isNull() && title.isEmpty())
+ {
+ title = titleForBookmarkUrl(bm, url); // it is .bookfolder
+ bm = group.next(bm);
+ }
+ }
+ else if(!bookmark.isSeparator() && bookmark.url()==url)
+ {
+ title = bookmark.fullText();
+ }
+
+ return title;
+}
+
+
+
diff --git a/src/bookmarks/bookmarksmanager.h b/src/bookmarks/bookmarksmanager.h
index 18ff3ef0..ace06e95 100644
--- a/src/bookmarks/bookmarksmanager.h
+++ b/src/bookmarks/bookmarksmanager.h
@@ -219,6 +219,8 @@ public:
*/
KCompletion *completionObject() const;
+ QString titleForBookmarkUrl(QString url);
+
signals:
/**
* @short This signal is emitted when an url has to be loaded
@@ -245,8 +247,10 @@ public slots:
*/
void slotBookmarksChanged(const QString &group, const QString &caller);
+
private:
KAction *fillBookmarkBar(const KBookmark &bookmark);
+ QString titleForBookmarkUrl(const KBookmark &bookmark, QString url);
KBookmarkManager *m_manager;
BookmarkOwner *m_owner;
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
index b2bf50af..cb61ad95 100644
--- a/src/urlbar/urlresolver.cpp
+++ b/src/urlbar/urlresolver.cpp
@@ -70,8 +70,17 @@ UrlSearchList UrlResolver::orderedSearchItems()
UrlSearchList list;
- list << qurlFromUserInputResolution();
- list << webSearchesResolution();
+ if(isHttp())
+ {
+ list << qurlFromUserInputResolution();
+ list << webSearchesResolution();
+ }
+ else
+ {
+ list << webSearchesResolution();
+ list << qurlFromUserInputResolution();
+ }
+
int firstResults = list.count();
int checkPoint = 9 - firstResults;
@@ -93,6 +102,21 @@ UrlSearchList UrlResolver::orderedSearchItems()
}
+bool UrlResolver::isHttp()
+{
+ QString r = "[\\d\\w-.]+\\.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|"\
+ "c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|"\
+ "h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|"\
+ "m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|"\
+ "s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|"\
+ "y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|"\
+ "pro)";
+
+ return (QRegExp(r, Qt::CaseInsensitive).indexIn(_urlString) != -1)
+ || _urlString.startsWith("http:")
+ || _urlString.startsWith("https:");
+}
+
//////////////////////////////////////////////////////////////////////////
// PRIVATE ENGINES
@@ -108,10 +132,12 @@ UrlSearchList UrlResolver::qurlFromUserInputResolution()
{
QByteArray ba = urlFromUserInput.toEncoded();
if(!ba.isEmpty())
- {
- QString str(ba);
- UrlSearchItem it(str);
- list << it;
+ {
+ QString gUrl = QString(ba);
+ QString gTitle = i18n("Browse");
+ UrlSearchItem gItem(gUrl, gTitle, QString("") );
+ list << gItem;
+
}
}
@@ -125,7 +151,7 @@ UrlSearchList UrlResolver::webSearchesResolution()
UrlSearchList list;
QString url1 = _urlString;
- if(KUrl(url1).isRelative() && !url1.contains('.'))
+ if(KUrl(url1).isRelative())
{
// KUriFilter has the worst performance possible here and let this trick unusable
QString gUrl = QString("http://www.google.com/search?q=%1&ie=UTF-8&oe=UTF-8").arg(url1);
@@ -133,10 +159,10 @@ UrlSearchList UrlResolver::webSearchesResolution()
UrlSearchItem gItem(gUrl, gTitle, QString("http://www.google.com") );
list << gItem;
- QString wUrl = QString("http://en.wikipedia.org/wiki/Special:Search?search=%1&go=Go").arg(url1);
- QString wTitle = i18n("Search Wikipedia for ") + url1;
- UrlSearchItem wItem(wUrl, wTitle, QString("http://wikipedia.org") );
- list << wItem;
+// QString wUrl = QString("http://en.wikipedia.org/wiki/Special:Search?search=%1&go=Go").arg(url1);
+// QString wTitle = i18n("Search Wikipedia for ") + url1;
+// UrlSearchItem wItem(wUrl, wTitle, QString("http://wikipedia.org") );
+// list << wItem;
}
return list;
@@ -169,9 +195,10 @@ UrlSearchList UrlResolver::bookmarksResolution()
QStringList bookmarkResults = bookmarkCompletion->substringCompletion(_urlString);
Q_FOREACH(const QString &s, bookmarkResults)
{
- UrlSearchItem it( s, QString(), QString("rating") );
+ UrlSearchItem it( s, Application::bookmarkProvider()->titleForBookmarkUrl(s), QString("rating") );
list << it;
}
+
return list;
}
diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h
index 0a880150..4231aaab 100644
--- a/src/urlbar/urlresolver.h
+++ b/src/urlbar/urlresolver.h
@@ -67,6 +67,7 @@ private:
UrlSearchList historyResolution();
UrlSearchList qurlFromUserInputResolution();
UrlSearchList bookmarksResolution();
+ bool isHttp();
};
#endif // URL_RESOLVER_H