summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-11-07 16:35:41 +0100
committerAndrea Diamantini <adjam7@gmail.com>2010-11-07 16:35:41 +0100
commit65e287ee4a68dcd5019d3fad13b3ebfdd1ef23d4 (patch)
tree379a3c99565c72a9f7315f2aef093e6a8c3af87e /src
parentcommit the changes by yurchor on the docbook (diff)
downloadrekonq-65e287ee4a68dcd5019d3fad13b3ebfdd1ef23d4.tar.xz
First bunch of fixes for the suggestions.
We are now respecting users setting on default engines (if someone chooses NONE default search engines, searches are NOT performed)
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp1
-rw-r--r--src/data/wikipedia.xml10
-rw-r--r--src/opensearch/searchengine.cpp10
-rw-r--r--src/urlbar/completionwidget.cpp3
-rw-r--r--src/urlbar/listitem.cpp31
-rw-r--r--src/urlbar/urlresolver.cpp24
-rw-r--r--src/urlbar/urlresolver.h7
7 files changed, 53 insertions, 33 deletions
diff --git a/src/application.cpp b/src/application.cpp
index cadfa50f..2efb62c0 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -310,7 +310,6 @@ OpenSearchManager *Application::opensearchManager()
if (s_opensearchManager.isNull())
{
s_opensearchManager = new OpenSearchManager(instance());
- s_opensearchManager.data()->setSearchProvider("google"); //TODO: use other suggestion engines
}
return s_opensearchManager.data();
}
diff --git a/src/data/wikipedia.xml b/src/data/wikipedia.xml
index 6f200a25..4e152087 100644
--- a/src/data/wikipedia.xml
+++ b/src/data/wikipedia.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
- <ShortName>Wikipédia (fr)</ShortName>
- <Description>Wikipédia (fr)</Description>
- <Url method="get" template="http://fr.wikipedia.org/w/index.php?title=Sp%C3%A9cial:Recherche&amp;search={searchTerms}"/>
- <Url method="get" type="application/x-suggestions+xml" template="http://fr.wikipedia.org/w/api.php?action=opensearch&amp;format=xml&amp;search={searchTerms}&amp;namespace=0"/>
- <Image>http://fr.wikipedia.org/favicon.ico</Image>
+ <ShortName>Wikipedia</ShortName>
+ <Description>Wikipedia</Description>
+ <Url method="get" template="http://en.wikipedia.org/w/index.php?title=Sp%C3%A9cial:Recherche&amp;search={searchTerms}"/>
+ <Url method="get" type="application/x-suggestions+xml" template="http://en.wikipedia.org/w/api.php?action=opensearch&amp;format=xml&amp;search={searchTerms}&amp;namespace=0"/>
+ <Image>http://en.wikipedia.org/favicon.ico</Image>
</OpenSearchDescription>
diff --git a/src/opensearch/searchengine.cpp b/src/opensearch/searchengine.cpp
index 415e5b35..44e35e33 100644
--- a/src/opensearch/searchengine.cpp
+++ b/src/opensearch/searchengine.cpp
@@ -74,11 +74,11 @@ void SearchEngine::reload()
//load default engine
QString d = cg.readEntry("DefaultSearchEngine");
m_defaultEngine = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(d));
- if (!m_defaultEngine)
- {
- d = QL1S("google");
- m_defaultEngine = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(d));
- }
+// if (!m_defaultEngine)
+// {
+// d = QL1S("google");
+// m_defaultEngine = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(d));
+// }
m_loaded = true;
}
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index f8bf6ee2..a42433b7 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -311,6 +311,9 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev)
child = findChild<ListItem *>(QString::number(_currentIndex));
if(child && _currentIndex!=0) //the completionwidget is visible and the user had press down
{
+ kDebug() << "USING LISTITEM URL: " << child->url();
+ kDebug() << "USING LISTITEM TITLE: " << child->text();
+
//we can use the url of the listitem
emit chosenUrl(child->url(), Rekonq::CurrentTab);
}
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index 5fa46470..a0462e76 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -58,6 +58,7 @@
#include <QFile>
#include <QTextDocument>
+
ListItem::ListItem(const UrlSearchItem &item, QWidget *parent)
: QWidget(parent)
, m_option()
@@ -81,7 +82,6 @@ ListItem::~ListItem()
}
-
void ListItem::activate()
{
m_option.state |= QStyle::State_Selected;
@@ -166,11 +166,16 @@ TypeIconLabel::TypeIconLabel(int type, QWidget *parent)
hLayout->setAlignment(Qt::AlignRight);
setLayout(hLayout);
- if (type & UrlSearchItem::Search) hLayout->addWidget(getIcon("edit-find"));
- 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"));
+ if (type & UrlSearchItem::Search)
+ hLayout->addWidget(getIcon("edit-find"));
+ 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"));
}
@@ -204,8 +209,10 @@ IconLabel::IconLabel(const KIcon &icon, QWidget *parent)
setPixmap(pixmapIcon);
}
+
// ---------------------------------------------------------------
+
static QString highlightWordsInText(const QString &text, const QStringList &words)
{
QString ret = text;
@@ -241,6 +248,7 @@ static QString highlightWordsInText(const QString &text, const QStringList &word
return ret;
}
+
TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget *parent)
: QLabel(parent)
{
@@ -274,6 +282,7 @@ void TextLabel::setEngineText(const QString &engine, const QString &text)
setText( i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for <b>%2</b>", engine, Qt::escape(text) ) );
}
+
// ---------------------------------------------------------------
@@ -350,6 +359,7 @@ PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *p
}
}
+
// ---------------------------------------------------------------
@@ -382,6 +392,7 @@ void ImageLabel::slotResult(KJob *)
setPixmap(pix);
}
+
// ---------------------------------------------------------------
@@ -416,12 +427,6 @@ QString SearchListItem::text()
}
-// QString SearchListItem::searchItemTitle(QString engine, QString text)
-// {
-// return QString(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for %2", engine, text));
-// }
-
-
void SearchListItem::changeSearchEngine(KService::Ptr engine)
{
m_titleLabel->setEngineText(engine->name(), m_text);
@@ -575,6 +580,7 @@ QString VisualSuggestionListItem::text()
return m_text;
}
+
// ---------------------------------------------------------------
@@ -627,6 +633,7 @@ ListItem *ListItemFactory::create(const UrlSearchItem &item, const QString &text
if (item.type & UrlSearchItem::Suggestion)
{
+ kDebug() << "ITEM URL: " << item.url;
if (item.description.isEmpty())
{
kDebug() << "Suggestion";
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
index c3efb903..c95557cf 100644
--- a/src/urlbar/urlresolver.cpp
+++ b/src/urlbar/urlresolver.cpp
@@ -70,7 +70,8 @@ UrlResolver::UrlResolver(const QString &typedUrl)
: QObject()
, _typedString(typedUrl.trimmed())
{
- if (!_searchEngine ) setSearchEngine(SearchEngine::defaultEngine());
+ if (!_searchEngine )
+ setSearchEngine(SearchEngine::defaultEngine());
if ( _browseRegexp.isEmpty() )
{
@@ -196,8 +197,8 @@ UrlSearchList UrlResolver::orderLists()
UrlSearchList common;
int commonCount = 0;
- //prefer items which are history items als well bookmarks item
- //if there are more than 1000 bookmark results, the performance impact is noticeable
+ // prefer items which are history items as well bookmarks item
+ // if there are more than 1000 bookmark results, the performance impact is noticeable
if(bookmarksCount < 1000)
{
//add as many items to the common list as there are available entries in the dropdown list
@@ -316,7 +317,7 @@ UrlSearchList UrlResolver::orderLists()
// PRIVATE ENGINES
-//QUrl from User Input (easily the best solution... )
+// QUrl from User Input (easily the best solution... )
void UrlResolver::computeQurlFromUserInput()
{
QString url = _typedString;
@@ -330,7 +331,7 @@ void UrlResolver::computeQurlFromUserInput()
}
-//webSearches
+// webSearches
void UrlResolver::computeWebSearches()
{
QString query = _typedString;
@@ -341,11 +342,17 @@ void UrlResolver::computeWebSearches()
_searchEngine = engine;
}
- _webSearches = (UrlSearchList() << UrlSearchItem(UrlSearchItem::Search, SearchEngine::buildQuery(_searchEngine, query), _searchEngine->name()));
+ if(_searchEngine)
+ {
+ UrlSearchItem item = UrlSearchItem(UrlSearchItem::Search, SearchEngine::buildQuery(_searchEngine, query), _searchEngine->name());
+ UrlSearchList list;
+ list << item;
+ _webSearches = list;
+ }
}
-//history
+// history
void UrlResolver::computeHistory()
{
QList<HistoryItem> found = Application::historyManager()->find(_typedString);
@@ -375,7 +382,7 @@ void UrlResolver::computeBookmarks()
}
-//opensearch suggestion
+// opensearch suggestion
void UrlResolver::computeSuggestions()
{
// if a string startsWith /, it is probably a local path
@@ -405,6 +412,7 @@ void UrlResolver::suggestionsReceived(const QString &text, const ResponseList &s
Q_FOREACH(const Response &i, suggestions)
{
+ kDebug() << "RESPONSE URL: " << i.url;
UrlSearchItem gItem(UrlSearchItem::Suggestion, i.url, i.title, i.description, i.image, i.image_width, i.image_height);
sugList << gItem;
}
diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h
index 3e8e4fce..e21e65e8 100644
--- a/src/urlbar/urlresolver.h
+++ b/src/urlbar/urlresolver.h
@@ -30,6 +30,8 @@
// Rekonq Includes
#include "rekonq_defines.h"
+
+// Locale Includes
#include "application.h"
#include "opensearchmanager.h"
@@ -87,7 +89,7 @@ public:
UrlSearchItem(const int &_type,
const QString &_url,
const QString &_title = QString(),
- const QString &_description = QString(),
+ const QString &_description = QString(),
const QString &_image = QString(),
const int &_image_width = 0,
const int &_image_height = 0
@@ -130,7 +132,8 @@ public:
static void setSearchEngine(KService::Ptr engine)
{
_searchEngine = engine;
- Application::opensearchManager()->setSearchProvider(engine->desktopEntryName());
+ if(engine)
+ Application::opensearchManager()->setSearchProvider(engine->desktopEntryName());
};
void computeSuggestions();