summaryrefslogtreecommitdiff
path: root/src/webtab.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-12-21 21:59:23 +0100
committerAndrea Diamantini <adjam7@gmail.com>2010-12-21 21:59:23 +0100
commit925725bfcf0f3ffba5107949bc8424e1fd6d1902 (patch)
treeee10e2c10e3ec63b0977661cfbc0ef69ad98002a /src/webtab.cpp
parentAdding a tab list menu entry showing all open tabs. (diff)
downloadrekonq-925725bfcf0f3ffba5107949bc8424e1fd6d1902.tar.xz
Icon at the right of the urlbar that allows to add an opensearch engine
introduce search icon description file downloaded after validation, not before icons updated when engine added add opensearch xml description files sync desktop file => fix add webshortcut use db_opensearch.json file to track opensearch engines create an opensearch description only when the engine support suggestions remove opensearch description when an engine is deleted in the webshortcut setting dialog popup: disable ok button when webshortcut is already used Lionel Chauvin is the man having done this big, big, big work!! I'm just merging ;)
Diffstat (limited to 'src/webtab.cpp')
-rw-r--r--src/webtab.cpp71
1 files changed, 66 insertions, 5 deletions
diff --git a/src/webtab.cpp b/src/webtab.cpp
index bac73fec..2641f9c9 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -28,7 +28,6 @@
// Self Includes
#include "webtab.h"
#include "webtab.moc"
-
// Auto Includes
#include "rekonq.h"
@@ -38,14 +37,22 @@
#include "rsswidget.h"
#include "walletbar.h"
#include "webpage.h"
+#include "webshortcutwidget.h"
+#include "application.h"
+#include "opensearchmanager.h"
// KDE Includes
#include <KWebWallet>
+#include <KStandardShortcut>
+#include <KMenu>
+#include <KActionMenu>
+#include <KWebView>
+#include <KDebug>
+#include <KBuildSycocaProgressDialog>
// Qt Includes
#include <QtGui/QVBoxLayout>
-
WebTab::WebTab(QWidget *parent)
: QWidget(parent)
, m_webView(new WebView(this))
@@ -95,7 +102,7 @@ KUrl WebTab::url()
kDebug() << "REKONQ PAGE. URL = " << page()->loadingUrl();
return page()->loadingUrl();
}
-
+
return view()->url();
}
@@ -178,7 +185,7 @@ bool WebTab::hasRSSInfo()
}
-void WebTab::showRSSInfo(QPoint pos)
+void WebTab::showRSSInfo(const QPoint &pos)
{
QWebElementCollection col = page()->mainFrame()->findAllElements("link[type=\"application/rss+xml\"]");
col.append(page()->mainFrame()->findAllElements("link[type=\"application/atom+xml\"]"));
@@ -228,10 +235,64 @@ void WebTab::setPart(KParts::ReadOnlyPart *p, const KUrl &u)
if(!m_part)
return;
-
+
// Part NO more exists. Let's clean up from webtab
m_webView->show();
qobject_cast<QVBoxLayout *>(layout())->removeWidget(m_part->widget());
delete m_part;
m_part = 0;
}
+
+
+KUrl WebTab::extractOpensearchUrl(QWebElement e)
+{
+ QString href = e.attribute(QLatin1String("href"));
+ KUrl url = KUrl(href);
+ if (!href.contains(":"))
+ {
+ KUrl docUrl = m_webView->url();
+ QString host = docUrl.scheme() + "://" + docUrl.host();
+ if (docUrl.port() != -1)
+ {
+ host += ":" + QString::number(docUrl.port());
+ }
+ url = KUrl(docUrl, href);
+ }
+ return url;
+}
+
+
+bool WebTab::hasNewSearchEngine()
+{
+ QWebElement e = page()->mainFrame()->findFirstElement(QLatin1String("head >link[rel=\"search\"][ type=\"application/opensearchdescription+xml\"]"));
+ return !e.isNull() && !Application::opensearchManager()->engineExists(extractOpensearchUrl(e));
+}
+
+
+void WebTab::showSearchEngine(const QPoint &pos)
+{
+ QWebElement e = page()->mainFrame()->findFirstElement(QLatin1String("head >link[rel=\"search\"][ type=\"application/opensearchdescription+xml\"]"));
+ QString title = e.attribute(QLatin1String("title"));
+ if (!title.isEmpty())
+ {
+ WebShortcutWidget *widget = new WebShortcutWidget(window());
+ widget->setWindowFlags(Qt::Popup);
+
+ connect(widget, SIGNAL(webShortcutSet(const KUrl &, const QString &, const QString &)),
+ Application::opensearchManager(), SLOT(addOpenSearchEngine(const KUrl &, const QString &, const QString &)));
+ connect(Application::opensearchManager(), SIGNAL(openSearchEngineAdded(const QString &, const QString &, const QString &)),
+ this, SLOT(openSearchEngineAdded()));
+
+ widget->show(extractOpensearchUrl(e), title, pos);
+ }
+}
+
+
+void WebTab::openSearchEngineAdded()
+{
+ // If the providers changed, tell sycoca to rebuild its database...
+ KBuildSycocaProgressDialog::rebuildKSycoca(this);
+
+ disconnect(Application::opensearchManager(), SIGNAL(openSearchEngineAdded(const QString &, const QString &, const QString &)),
+ this, SLOT(openSearchEngineAdded()));
+}