summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Franke <nobody@nowhere.ws>2012-03-21 13:41:35 (GMT)
committerChristian Franke <nobody@nowhere.ws>2012-03-21 13:41:35 (GMT)
commit966c8701a7c90342d220f4a0374e1e1290c0c393 (patch)
treefeeac788b79033ec8c12eb82048aefa19f27f074
parent6f48161222251f96e5ded3db28045295ee576b46 (diff)
Use new API for search from context menu
-rw-r--r--src/tabwidget.cpp26
-rw-r--r--src/tabwidget.h3
-rw-r--r--src/webview.cpp2
-rw-r--r--src/webview.h5
4 files changed, 25 insertions, 11 deletions
diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp
index beb7dfb..015c770 100644
--- a/src/tabwidget.cpp
+++ b/src/tabwidget.cpp
@@ -407,8 +407,8 @@ WebView *TabWidget::makeNewTab(bool makeCurrent)
this, SLOT(webViewTitleChanged(const QString &)));
connect(webView, SIGNAL(urlChanged(const QUrl &)),
this, SLOT(webViewUrlChanged(const QUrl &)));
- connect(webView, SIGNAL(search(const QUrl&, TabWidget::OpenUrlIn)),
- this, SLOT(loadUrl(const QUrl&, TabWidget::OpenUrlIn)));
+ connect(webView, SIGNAL(search(const QString&, TabWidget::OpenUrlIn, OpenSearchEngine*)),
+ this, SLOT(performSearch(const QString&, TabWidget::OpenUrlIn, OpenSearchEngine*)));
connect(webView->page(), SIGNAL(windowCloseRequested()),
this, SLOT(windowCloseRequested()));
connect(webView->page(), SIGNAL(printRequested(QWebFrame *)),
@@ -950,19 +950,29 @@ void TabWidget::loadUrl(const QUrl &url, OpenUrlIn tab, const QString &title)
/*
Somewhere in the browser interface a users wants to search for something.
*/
-void TabWidget::performSearch(const QString &term, OpenUrlIn tab)
+void TabWidget::performSearch(const QString &term, OpenUrlIn tab,
+ OpenSearchEngine *engine)
{
+ if (!engine)
+ engine = ToolbarSearch::openSearchManager()->currentEngine();
+
+ if (!engine) {
+ qWarning() << "perfomSearchWithEngine: engine is null";
+ return;
+ }
+
if (tab == UserOrCurrent) {
tab = modifyWithUserBehavior(CurrentTab);
}
WebView *webView = getView(tab, currentWebView());
- if (webView) {
- OpenSearchEngine *engine = ToolbarSearch::openSearchManager()->currentEngine();
- engine->setDelegate(webView);
- engine->requestSearchResults(term);
- engine->setDelegate(NULL);
+ if (!webView) {
+ return;
}
+
+ engine->setDelegate(webView);
+ engine->requestSearchResults(term);
+ engine->setDelegate(NULL);
}
/*
diff --git a/src/tabwidget.h b/src/tabwidget.h
index be6ff75..ee1a3b3 100644
--- a/src/tabwidget.h
+++ b/src/tabwidget.h
@@ -77,6 +77,7 @@ class QStackedWidget;
QT_END_NAMESPACE
class BrowserMainWindow;
+class OpenSearchEngine;
class TabBar;
class WebView;
class WebActionMapper;
@@ -155,7 +156,7 @@ public slots:
void loadString(const QString &string, OpenUrlIn tab = CurrentTab);
void loadUrlFromUser(const QUrl &url, const QString &title = QString());
void loadUrl(const QUrl &url, TabWidget::OpenUrlIn tab = CurrentTab, const QString &title = QString());
- void performSearch(const QString &term, TabWidget::OpenUrlIn tab = CurrentTab);
+ void performSearch(const QString &term, TabWidget::OpenUrlIn tab = CurrentTab, OpenSearchEngine *engine = NULL);
void createTab(const QByteArray &historyState, TabWidget::OpenUrlIn tab = CurrentTab);
void newTab();
void cloneTab(int index = -1);
diff --git a/src/webview.cpp b/src/webview.cpp
index 2c9b046..60f72b5 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -411,7 +411,7 @@ void WebView::searchRequested(QAction *action)
if (index.canConvert<QString>()) {
OpenSearchEngine *engine = ToolbarSearch::openSearchManager()->engine(index.toString());
- emit search(engine->searchUrl(searchText), TabWidget::NewSelectedTab);
+ emit search(searchText, TabWidget::NewSelectedTab, engine);
}
}
diff --git a/src/webview.h b/src/webview.h
index f4a7447..1b8b0b4 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -75,6 +75,7 @@ class QLabel;
#endif
class BrowserMainWindow;
+class OpenSearchEngine;
class TabWidget;
class WebPage;
class WebView : public QWebView, public OpenSearchEngineDelegate
@@ -106,7 +107,9 @@ public:
TabWidget *tabWidget() const;
signals:
- void search(const QUrl &searchUrl, TabWidget::OpenUrlIn openIn);
+ void search(const QString &term,
+ TabWidget::OpenUrlIn openIn,
+ OpenSearchEngine *engine);
public slots:
void zoomIn();