summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/opensearch/opensearchmanager.cpp100
-rw-r--r--src/opensearch/opensearchmanager.h4
-rw-r--r--src/opensearch/opensearchreader.cpp1
-rw-r--r--src/tabpreviewpopup.cpp1
-rw-r--r--src/urlbar/urlbar.cpp3
-rw-r--r--src/urlbar/webshortcutwidget.cpp9
-rw-r--r--src/urlbar/webshortcutwidget.h14
-rw-r--r--src/webtab.cpp2
-rw-r--r--src/webtab.h12
9 files changed, 80 insertions, 66 deletions
diff --git a/src/opensearch/opensearchmanager.cpp b/src/opensearch/opensearchmanager.cpp
index 12b93ec2..fa225264 100644
--- a/src/opensearch/opensearchmanager.cpp
+++ b/src/opensearch/opensearchmanager.cpp
@@ -115,9 +115,8 @@ bool OpenSearchManager::isSuggestionAvailable()
void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &title, const QString &shortcut)
{
- Q_UNUSED(title);
-
m_shortcut = shortcut;
+ m_title = trimmedEngineName(title);
if (m_state != IDLE)
{
@@ -170,67 +169,49 @@ void OpenSearchManager::dataReceived(KIO::Job *job, const QByteArray &data)
void OpenSearchManager::jobFinished(KJob *job)
{
- // Do NOT parse if job had same errors or the typed string is empty
- if (job->error() || _typedText.isEmpty())
- {
- emit suggestionsReceived(_typedText, ResponseList());
- m_state = IDLE;
- return; // just silently return
- }
-
- if (m_state == REQ_SUGGESTION)
- {
- ResponseList suggestionsList;
- if (isSuggestionAvailable())
- {
- suggestionsList = m_activeEngine->parseSuggestion(_typedText, m_jobData);
- }
- emit suggestionsReceived(_typedText, suggestionsList);
- idleJob();
- return;
- }
-
- if (m_state == REQ_DESCRIPTION)
+ if (!job->error() && m_state == REQ_DESCRIPTION)
{
OpenSearchReader reader;
OpenSearchEngine *engine = reader.read(m_jobData);
if (engine)
{
- m_engineCache.insert(engine->name(), engine);
- m_engines.insert(m_jobUrl, trimmedEngineName(engine->name()));
+ m_engineCache.insert(m_title, engine);
+ m_engines.insert(m_jobUrl, m_shortcut);
saveEngines();
QString path;
- if (engine->providesSuggestions()) //save opensearch description only if it provides suggestions
+ if (engine->providesSuggestions())
{
+ // save opensearch description only if it provides suggestions
OpenSearchWriter writer;
path = KGlobal::dirs()->findResource("data", "rekonq/opensearch/");
QFile file(path + trimmedEngineName(engine->name()) + ".xml");
writer.write(&file, engine);
- }
- QString searchUrl = OpenSearchEngine::parseTemplate("\\{@}", engine->searchUrlTemplate());
- m_currentJob = NULL;
-
- path = KGlobal::mainComponent().dirs()->saveLocation("services", "searchproviders/");
- KConfig _service(path + trimmedEngineName(engine->name()) + ".desktop", KConfig::SimpleConfig);
- KConfigGroup service(&_service, "Desktop Entry");
- service.writeEntry("Type", "Service");
- service.writeEntry("ServiceTypes", "SearchProvider");
- service.writeEntry("Name", engine->name());
- service.writeEntry("Query", searchUrl);
- service.writeEntry("Keys", m_shortcut);
- // TODO charset
- service.writeEntry("Charset", "" /* provider->charset() */);
- // we might be overwriting a hidden entry
- service.writeEntry("Hidden", false);
- service.sync();
-
- // Update filters in running applications...
- QDBusMessage msg = QDBusMessage::createSignal("/", "org.kde.KUriFilterPlugin", "configure");
- QDBusConnection::sessionBus().send(msg);
-
- emit openSearchEngineAdded(engine->name(), searchUrl, m_shortcut);
+ // save desktop file here
+ QString searchUrl = OpenSearchEngine::parseTemplate("\\{@}", engine->searchUrlTemplate());
+ m_currentJob = NULL;
+
+ path = KGlobal::mainComponent().dirs()->saveLocation("services", "searchproviders/");
+ KConfig _service(path + m_title + ".desktop", KConfig::SimpleConfig);
+ KConfigGroup service(&_service, "Desktop Entry");
+ service.writeEntry("Type", "Service");
+ service.writeEntry("ServiceTypes", "SearchProvider");
+ service.writeEntry("Name", m_title);
+ service.writeEntry("Query", searchUrl);
+ service.writeEntry("Keys", m_shortcut);
+ // TODO charset
+ service.writeEntry("Charset", "" /* provider->charset() */);
+ // we might be overwriting a hidden entry
+ service.writeEntry("Hidden", false);
+ service.sync();
+
+ // Update filters in running applications...
+ QDBusMessage msg = QDBusMessage::createSignal("/", "org.kde.KUriFilterPlugin", "configure");
+ QDBusConnection::sessionBus().send(msg);
+
+ emit openSearchEngineAdded(engine->name());
+ }
}
else
{
@@ -238,6 +219,27 @@ void OpenSearchManager::jobFinished(KJob *job)
}
idleJob();
+ return;
+ }
+
+ // Do NOT parse if job had same errors or the typed string is empty
+ if (job->error() || _typedText.isEmpty())
+ {
+ emit suggestionsReceived(_typedText, ResponseList());
+ m_state = IDLE;
+ return; // just silently return
+ }
+
+ if (m_state == REQ_SUGGESTION)
+ {
+ ResponseList suggestionsList;
+ if (isSuggestionAvailable())
+ {
+ suggestionsList = m_activeEngine->parseSuggestion(_typedText, m_jobData);
+ }
+ emit suggestionsReceived(_typedText, suggestionsList);
+ idleJob();
+ return;
}
}
diff --git a/src/opensearch/opensearchmanager.h b/src/opensearch/opensearchmanager.h
index 84272f26..49e905c8 100644
--- a/src/opensearch/opensearchmanager.h
+++ b/src/opensearch/opensearchmanager.h
@@ -97,7 +97,7 @@ private Q_SLOTS:
Q_SIGNALS:
void suggestionsReceived(const QString &text, const ResponseList &suggestion);
- void openSearchEngineAdded(const QString &name, const QString &searchUrl, const QString &fileName);
+ void openSearchEngineAdded(const QString &name);
private:
QString trimmedEngineName(const QString &engineName) const;
@@ -117,7 +117,9 @@ private:
KUrl m_jobUrl;
QString _typedText;
+
QString m_shortcut;
+ QString m_title;
};
#endif // OPENSEARCHMANAGER_H
diff --git a/src/opensearch/opensearchreader.cpp b/src/opensearch/opensearchreader.cpp
index c2bf0f09..0a93d104 100644
--- a/src/opensearch/opensearchreader.cpp
+++ b/src/opensearch/opensearchreader.cpp
@@ -83,6 +83,7 @@ OpenSearchEngine *OpenSearchReader::read()
|| namespaceUri() != QL1S("http://a9.com/-/spec/opensearch/1.1/")
)
{
+ kDebug() << "The file is not an OpenSearch 1.1 file: " << name();
raiseError(i18n("The file is not an OpenSearch 1.1 file."));
return engine;
}
diff --git a/src/tabpreviewpopup.cpp b/src/tabpreviewpopup.cpp
index 4466868d..c5e0efca 100644
--- a/src/tabpreviewpopup.cpp
+++ b/src/tabpreviewpopup.cpp
@@ -29,6 +29,7 @@
#include "tabpreviewpopup.h"
// Rekonq Includes
+#include "webpage.h"
#include "webtab.h"
#include "tabbar.h"
#include "websnap.h"
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 43109db3..c606989e 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -133,8 +133,7 @@ UrlBar::UrlBar(QWidget *parent)
connect(_tab->view(), SIGNAL(iconChanged()), this, SLOT(refreshFavicon()));
// search icon
- connect(rApp->opensearchManager(), SIGNAL(openSearchEngineAdded(QString,QString,QString)),
- this, SLOT(updateRightIcons()));
+ connect(rApp->opensearchManager(), SIGNAL(openSearchEngineAdded(QString)), this, SLOT(updateRightIcons()));
// bookmark icon
connect(rApp->bookmarkManager(), SIGNAL(bookmarksUpdated()), this, SLOT(updateRightIcons()));
diff --git a/src/urlbar/webshortcutwidget.cpp b/src/urlbar/webshortcutwidget.cpp
index d44f6f1a..6ae7a648 100644
--- a/src/urlbar/webshortcutwidget.cpp
+++ b/src/urlbar/webshortcutwidget.cpp
@@ -4,6 +4,7 @@
*
* Copyright (C) 2009 by Fredy Yanardi <fyanardi@gmail.com>
* Copyright (C) 2010-2011 by Lionel Chauvin <megabigbug@yahoo.fr>
+* Copyright (C) 2012 by Andrea Diamantini <adjam7 at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or
@@ -27,7 +28,7 @@
// Self Includes
#include "webshortcutwidget.h"
-#include "rekonq_defines.h"
+#include "webshortcutwidget.moc"
// KDE Includes
#include <KGlobalSettings>
@@ -112,6 +113,8 @@ void WebShortcutWidget::show(const KUrl &url, const QString &openSearchName, con
void WebShortcutWidget::accept()
{
emit webShortcutSet(m_url, m_nameLineEdit->text(), m_wsLineEdit->text());
+
+ // close widget (and destroy it)
close();
}
@@ -157,7 +160,3 @@ void WebShortcutWidget::shortcutsChanged(const QString& newShorthands)
}
}
}
-
-#include "webshortcutwidget.moc"
-
-
diff --git a/src/urlbar/webshortcutwidget.h b/src/urlbar/webshortcutwidget.h
index bc072f47..d1291714 100644
--- a/src/urlbar/webshortcutwidget.h
+++ b/src/urlbar/webshortcutwidget.h
@@ -4,6 +4,7 @@
*
* Copyright (C) 2009 by Fredy Yanardi <fyanardi@gmail.com>
* Copyright (C) 2010-2011 by Lionel Chauvin <megabigbug@yahoo.fr>
+* Copyright (C) 2012 by Andrea Diamantini <adjam7 at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or
@@ -28,15 +29,24 @@
#ifndef WEBSHORTCUTWIDGET_H
#define WEBSHORTCUTWIDGET_H
-#include <QMenu>
+
+// Rekonq Includes
+#include "rekonq_defines.h"
+
+// KDE Includes
#include <KUrl>
#include <KService>
+// Qt Includes
+#include <QMenu>
+
+// Forward Declarations
class QLabel;
class QLineEdit;
class QPushButton;
-class WebShortcutWidget : public QMenu
+
+class REKONQ_TESTS_EXPORT WebShortcutWidget : public QMenu
{
Q_OBJECT
public:
diff --git a/src/webtab.cpp b/src/webtab.cpp
index 57f46ea4..09c64054 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -318,7 +318,7 @@ void WebTab::showSearchEngine(const QPoint &pos)
connect(widget, SIGNAL(webShortcutSet(KUrl,QString,QString)),
rApp->opensearchManager(), SLOT(addOpenSearchEngine(KUrl,QString,QString)));
- connect(rApp->opensearchManager(), SIGNAL(openSearchEngineAdded(QString,QString,QString)),
+ connect(rApp->opensearchManager(), SIGNAL(openSearchEngineAdded(QString)),
this, SLOT(openSearchEngineAdded()));
widget->show(extractOpensearchUrl(e), title, pos);
diff --git a/src/webtab.h b/src/webtab.h
index 5c04b683..39bffdb7 100644
--- a/src/webtab.h
+++ b/src/webtab.h
@@ -33,21 +33,21 @@
#include "rekonq_defines.h"
// Local Includes
-#include "webpage.h"
#include "webview.h"
// KDE Includes
#include <KParts/Part>
// Qt Includes
-#include <QtGui/QWidget>
+#include <QWidget>
// Forward Declarations
-class UrlBar;
-class PreviewSelectorBar;
-class WalletBar;
class NotificationBar;
+class PreviewSelectorBar;
class QPoint;
+class UrlBar;
+class WalletBar;
+class WebPage;
class REKONQ_TESTS_EXPORT WebTab : public QWidget
@@ -97,7 +97,7 @@ private Q_SLOTS:
void showRSSInfo(const QPoint &pos);
void showSearchEngine(const QPoint &pos);
void openSearchEngineAdded();
-
+
void showMessageBar();
private: