Browse files

Pass the WebPageManager to each command

  • Loading branch information...
1 parent bfbda84 commit f80125e6cb563d25e90df1da70b9991026a19cae @mhoran mhoran committed Apr 4, 2012
Showing with 109 additions and 134 deletions.
  1. +1 −3 src/Body.h
  2. +2 −1 src/ClearCookies.cpp
  3. +1 −3 src/ClearCookies.h
  4. +8 −3 src/Command.cpp
  5. +4 −2 src/Command.h
  6. +1 −5 src/CommandFactory.cpp
  7. +2 −3 src/CommandFactory.h
  8. +0 −1 src/Connection.cpp
  9. +2 −1 src/ConsoleMessages.cpp
  10. +1 −3 src/ConsoleMessages.h
  11. +2 −1 src/CurrentUrl.cpp
  12. +1 −3 src/CurrentUrl.h
  13. +2 −1 src/Evaluate.cpp
  14. +1 −3 src/Evaluate.h
  15. +2 −1 src/Execute.cpp
  16. +1 −3 src/Execute.h
  17. +2 −1 src/Find.cpp
  18. +1 −3 src/Find.h
  19. +2 −1 src/FrameFocus.cpp
  20. +1 −2 src/FrameFocus.h
  21. +2 −1 src/GetCookies.cpp
  22. +1 −3 src/GetCookies.h
  23. +2 −1 src/GetWindowHandle.cpp
  24. +1 −3 src/GetWindowHandle.h
  25. +2 −3 src/GetWindowHandles.cpp
  26. +1 −3 src/GetWindowHandles.h
  27. +2 −1 src/Header.cpp
  28. +1 −3 src/Header.h
  29. +2 −1 src/Headers.cpp
  30. +1 −3 src/Headers.h
  31. +3 −2 src/IgnoreSslErrors.cpp
  32. +1 −3 src/IgnoreSslErrors.h
  33. +2 −1 src/Node.cpp
  34. +1 −3 src/Node.h
  35. +2 −1 src/NullCommand.cpp
  36. +1 −3 src/NullCommand.h
  37. +2 −1 src/Render.cpp
  38. +1 −3 src/Render.h
  39. +2 −1 src/RequestedUrl.cpp
  40. +1 −3 src/RequestedUrl.h
  41. +2 −1 src/Reset.cpp
  42. +1 −3 src/Reset.h
  43. +2 −1 src/ResizeWindow.cpp
  44. +1 −3 src/ResizeWindow.h
  45. +2 −1 src/SetCookie.cpp
  46. +1 −3 src/SetCookie.h
  47. +2 −1 src/SetProxy.cpp
  48. +1 −3 src/SetProxy.h
  49. +3 −2 src/SetSkipImageLoading.cpp
  50. +1 −3 src/SetSkipImageLoading.h
  51. +2 −1 src/Source.cpp
  52. +1 −2 src/Source.h
  53. +2 −1 src/Status.cpp
  54. +1 −3 src/Status.h
  55. +2 −1 src/Url.cpp
  56. +1 −3 src/Url.h
  57. +2 −1 src/Visit.cpp
  58. +1 −3 src/Visit.h
  59. +4 −0 src/WebPage.cpp
  60. +1 −0 src/WebPage.h
  61. +1 −1 src/WebPageManager.cpp
  62. +3 −4 src/WindowFocus.cpp
  63. +1 −3 src/WindowFocus.h
  64. +2 −1 src/body.cpp
  65. +1 −2 src/find_command.h
View
4 src/Body.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class Body : public Command {
Q_OBJECT
public:
- Body(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Body(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/ClearCookies.cpp
@@ -1,9 +1,10 @@
#include "ClearCookies.h"
#include "WebPage.h"
+#include "WebPageManager.h"
#include "NetworkCookieJar.h"
#include <QNetworkCookie>
-ClearCookies::ClearCookies(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {}
+ClearCookies::ClearCookies(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {}
void ClearCookies::start()
{
View
4 src/ClearCookies.h
@@ -1,11 +1,9 @@
#include "Command.h"
-class WebPage;
-
class ClearCookies : public Command {
Q_OBJECT;
public:
- ClearCookies(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ ClearCookies(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
11 src/Command.cpp
@@ -1,19 +1,24 @@
#include "Command.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-Command::Command(WebPage *page, QStringList &arguments, QObject *parent) : QObject(parent) {
- m_page = page;
+Command::Command(WebPageManager *manager, QStringList &arguments, QObject *parent) : QObject(parent) {
+ m_manager = manager;
m_arguments = arguments;
}
void Command::start() {
}
WebPage *Command::page() {
- return m_page;
+ return m_manager->currentPage();
}
QStringList &Command::arguments() {
return m_arguments;
}
+WebPageManager *Command::manager() {
+ return m_manager;
+}
+
View
6 src/Command.h
@@ -6,12 +6,13 @@
#include "Response.h"
class WebPage;
+class WebPageManager;
class Command : public QObject {
Q_OBJECT
public:
- Command(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Command(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
signals:
@@ -20,10 +21,11 @@ class Command : public QObject {
protected:
WebPage *page();
QStringList &arguments();
+ WebPageManager *manager();
private:
- WebPage *m_page;
QStringList m_arguments;
+ WebPageManager *m_manager;
};
View
6 src/CommandFactory.cpp
@@ -38,9 +38,5 @@ Command *CommandFactory::createCommand(const char *name, QStringList &arguments)
#include "find_command.h"
arguments.clear();
arguments.append(QString(name));
- return new NullCommand(currentPage(), arguments);
-}
-
-WebPage *CommandFactory::currentPage() {
- return m_manager->currentPage();
+ return new NullCommand(m_manager, arguments);
}
View
5 src/CommandFactory.h
@@ -8,11 +8,10 @@ class CommandFactory : public QObject {
Q_OBJECT
public:
- CommandFactory(WebPageManager *page, QObject *parent = 0);
+ CommandFactory(WebPageManager *, QObject *parent = 0);
Command *createCommand(const char *name, QStringList &arguments);
- WebPageManager *m_manager;
private:
- WebPage *currentPage();
+ WebPageManager *m_manager;
};
View
1 src/Connection.cpp
@@ -12,7 +12,6 @@ Connection::Connection(QTcpSocket *socket, WebPageManager *manager, QObject *par
QObject(parent) {
m_socket = socket;
m_manager = manager;
- m_manager->setCurrentPage(m_manager->createPage(this));
m_commandFactory = new CommandFactory(m_manager, this);
m_commandParser = new CommandParser(socket, m_commandFactory, this);
m_pageSuccess = true;
View
3 src/ConsoleMessages.cpp
@@ -1,7 +1,8 @@
#include "ConsoleMessages.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-ConsoleMessages::ConsoleMessages(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+ConsoleMessages::ConsoleMessages(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void ConsoleMessages::start() {
View
4 src/ConsoleMessages.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class ConsoleMessages : public Command {
Q_OBJECT
public:
- ConsoleMessages(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ ConsoleMessages(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/CurrentUrl.cpp
@@ -1,7 +1,8 @@
#include "CurrentUrl.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-CurrentUrl::CurrentUrl(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+CurrentUrl::CurrentUrl(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
/*
View
4 src/CurrentUrl.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class CurrentUrl : public Command {
Q_OBJECT
public:
- CurrentUrl(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ CurrentUrl(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
private:
View
3 src/Evaluate.cpp
@@ -1,8 +1,9 @@
#include "Evaluate.h"
#include "WebPage.h"
+#include "WebPageManager.h"
#include <iostream>
-Evaluate::Evaluate(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Evaluate::Evaluate(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
m_buffer = "";
}
View
4 src/Evaluate.h
@@ -2,13 +2,11 @@
#include <QVariantList>
-class WebPage;
-
class Evaluate : public Command {
Q_OBJECT
public:
- Evaluate(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Evaluate(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
private:
View
3 src/Execute.cpp
@@ -1,7 +1,8 @@
#include "Execute.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-Execute::Execute(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Execute::Execute(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Execute::start() {
View
4 src/Execute.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class Execute : public Command {
Q_OBJECT
public:
- Execute(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Execute(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/Find.cpp
@@ -1,8 +1,9 @@
#include "Find.h"
#include "Command.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-Find::Find(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Find::Find(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Find::start() {
View
4 src/Find.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class Find : public Command {
Q_OBJECT
public:
- Find(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Find(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/FrameFocus.cpp
@@ -1,8 +1,9 @@
#include "FrameFocus.h"
#include "Command.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-FrameFocus::FrameFocus(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+FrameFocus::FrameFocus(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void FrameFocus::start() {
View
3 src/FrameFocus.h
@@ -1,13 +1,12 @@
#include "Command.h"
-class WebPage;
class QWebFrame;
class FrameFocus : public Command {
Q_OBJECT
public:
- FrameFocus(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ FrameFocus(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
private:
View
3 src/GetCookies.cpp
@@ -1,8 +1,9 @@
#include "GetCookies.h"
#include "WebPage.h"
+#include "WebPageManager.h"
#include "NetworkCookieJar.h"
-GetCookies::GetCookies(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent)
+GetCookies::GetCookies(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent)
{
m_buffer = "";
}
View
4 src/GetCookies.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class GetCookies : public Command {
Q_OBJECT;
public:
- GetCookies(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ GetCookies(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
private:
View
3 src/GetWindowHandle.cpp
@@ -1,8 +1,9 @@
#include "GetWindowHandle.h"
#include "WebPage.h"
+#include "WebPageManager.h"
#include <QStringList>
-GetWindowHandle::GetWindowHandle(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+GetWindowHandle::GetWindowHandle(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void GetWindowHandle::start() {
View
4 src/GetWindowHandle.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class GetWindowHandle : public Command {
Q_OBJECT
public:
- GetWindowHandle(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ GetWindowHandle(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
5 src/GetWindowHandles.cpp
@@ -4,12 +4,11 @@
#include "WebPage.h"
#include <QStringList>
-GetWindowHandles::GetWindowHandles(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+GetWindowHandles::GetWindowHandles(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void GetWindowHandles::start() {
- QListIterator<WebPage *> pageIterator =
- ((CommandFactory *) parent())->m_manager->iterator();
+ QListIterator<WebPage *> pageIterator = manager()->iterator();
QString handles = "[";
QStringList stringList;
View
4 src/GetWindowHandles.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class GetWindowHandles : public Command {
Q_OBJECT
public:
- GetWindowHandles(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ GetWindowHandles(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/Header.cpp
@@ -1,8 +1,9 @@
#include "Header.h"
#include "WebPage.h"
+#include "WebPageManager.h"
#include "NetworkAccessManager.h"
-Header::Header(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Header::Header(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Header::start() {
View
4 src/Header.h
@@ -1,11 +1,9 @@
#include "Command.h"
-class WebPage;
-
class Header : public Command {
Q_OBJECT
public:
- Header(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Header(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/Headers.cpp
@@ -1,7 +1,8 @@
#include "Headers.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-Headers::Headers(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Headers::Headers(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Headers::start() {
View
4 src/Headers.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class Headers : public Command {
Q_OBJECT
public:
- Headers(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Headers(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
5 src/IgnoreSslErrors.cpp
@@ -1,8 +1,9 @@
#include "IgnoreSslErrors.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-IgnoreSslErrors::IgnoreSslErrors(WebPage *page, QStringList &arguments, QObject *parent) :
- Command(page, arguments, parent) {
+IgnoreSslErrors::IgnoreSslErrors(WebPageManager *manager, QStringList &arguments, QObject *parent) :
+ Command(manager, arguments, parent) {
}
void IgnoreSslErrors::start() {
View
4 src/IgnoreSslErrors.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class IgnoreSslErrors : public Command {
Q_OBJECT
public:
- IgnoreSslErrors(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ IgnoreSslErrors(WebPageManager *manager, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/Node.cpp
@@ -1,7 +1,8 @@
#include "Node.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-Node::Node(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Node::Node(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Node::start() {
View
4 src/Node.h
@@ -1,13 +1,11 @@
#include "Command.h"
#include <QStringList>
-class WebPage;
-
class Node : public Command {
Q_OBJECT
public:
- Node(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Node(WebPageManager *manager, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/NullCommand.cpp
@@ -1,7 +1,8 @@
#include "NullCommand.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-NullCommand::NullCommand(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {}
+NullCommand::NullCommand(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {}
void NullCommand::start() {
QString failure = QString("[Capybara WebKit] Unknown command: ") + arguments()[0] + "\n";
View
4 src/NullCommand.h
@@ -1,11 +1,9 @@
#include "Command.h"
-class WebPage;
-
class NullCommand : public Command {
Q_OBJECT
public:
- NullCommand(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ NullCommand(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/Render.cpp
@@ -1,7 +1,8 @@
#include "Render.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-Render::Render(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Render::Render(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Render::start() {
View
4 src/Render.h
@@ -1,12 +1,10 @@
#include "Command.h"
#include <QStringList>
-class WebPage;
-
class Render : public Command {
Q_OBJECT
public:
- Render(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Render(WebPageManager *page, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/RequestedUrl.cpp
@@ -1,7 +1,8 @@
#include "RequestedUrl.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-RequestedUrl::RequestedUrl(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+RequestedUrl::RequestedUrl(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void RequestedUrl::start() {
View
4 src/RequestedUrl.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class RequestedUrl : public Command {
Q_OBJECT
public:
- RequestedUrl(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ RequestedUrl(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/Reset.cpp
@@ -1,9 +1,10 @@
#include "Reset.h"
#include "WebPage.h"
+#include "WebPageManager.h"
#include "NetworkAccessManager.h"
#include "NetworkCookieJar.h"
-Reset::Reset(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Reset::Reset(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Reset::start() {
View
4 src/Reset.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class Reset : public Command {
Q_OBJECT
public:
- Reset(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Reset(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
private:
View
3 src/ResizeWindow.cpp
@@ -1,7 +1,8 @@
#include "ResizeWindow.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-ResizeWindow::ResizeWindow(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+ResizeWindow::ResizeWindow(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void ResizeWindow::start() {
View
4 src/ResizeWindow.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class ResizeWindow : public Command {
Q_OBJECT
public:
- ResizeWindow(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ ResizeWindow(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/SetCookie.cpp
@@ -1,9 +1,10 @@
#include "SetCookie.h"
#include "WebPage.h"
+#include "WebPageManager.h"
#include "NetworkCookieJar.h"
#include <QNetworkCookie>
-SetCookie::SetCookie(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {}
+SetCookie::SetCookie(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {}
void SetCookie::start()
{
View
4 src/SetCookie.h
@@ -1,11 +1,9 @@
#include "Command.h"
-class WebPage;
-
class SetCookie : public Command {
Q_OBJECT;
public:
- SetCookie(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ SetCookie(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/SetProxy.cpp
@@ -1,9 +1,10 @@
#include "SetProxy.h"
#include "WebPage.h"
+#include "WebPageManager.h"
#include <QNetworkAccessManager>
#include <QNetworkProxy>
-SetProxy::SetProxy(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {}
+SetProxy::SetProxy(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {}
void SetProxy::start()
{
View
4 src/SetProxy.h
@@ -1,11 +1,9 @@
#include "Command.h"
-class WebPage;
-
class SetProxy : public Command {
Q_OBJECT;
public:
- SetProxy(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ SetProxy(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
5 src/SetSkipImageLoading.cpp
@@ -1,8 +1,9 @@
#include "SetSkipImageLoading.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-SetSkipImageLoading::SetSkipImageLoading(WebPage *page, QStringList &arguments, QObject *parent) :
- Command(page, arguments, parent) {
+SetSkipImageLoading::SetSkipImageLoading(WebPageManager *manager, QStringList &arguments, QObject *parent) :
+ Command(manager, arguments, parent) {
}
void SetSkipImageLoading::start() {
View
4 src/SetSkipImageLoading.h
@@ -1,11 +1,9 @@
#include "Command.h"
-class WebPage;
-
class SetSkipImageLoading : public Command {
Q_OBJECT
public:
- SetSkipImageLoading(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ SetSkipImageLoading(WebPageManager *manager, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/Source.cpp
@@ -1,7 +1,8 @@
#include "Source.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-Source::Source(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Source::Source(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Source::start() {
View
3 src/Source.h
@@ -1,13 +1,12 @@
#include "Command.h"
-class WebPage;
class QNetworkReply;
class Source : public Command {
Q_OBJECT
public:
- Source(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Source(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
public slots:
View
3 src/Status.cpp
@@ -1,8 +1,9 @@
#include "Status.h"
#include "WebPage.h"
+#include "WebPageManager.h"
#include <sstream>
-Status::Status(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Status::Status(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Status::start() {
View
4 src/Status.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class Status : public Command {
Q_OBJECT
public:
- Status(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Status(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/Url.cpp
@@ -1,7 +1,8 @@
#include "Url.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-Url::Url(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Url::Url(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Url::start() {
View
4 src/Url.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class Url : public Command {
Q_OBJECT
public:
- Url(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Url(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
3 src/Visit.cpp
@@ -1,8 +1,9 @@
#include "Visit.h"
#include "Command.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-Visit::Visit(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Visit::Visit(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Visit::start() {
View
4 src/Visit.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class Visit : public Command {
Q_OBJECT
public:
- Visit(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ Visit(WebPageManager *manager, QStringList &arguments, QObject *parent = 0);
virtual void start();
};
View
4 src/WebPage.cpp
@@ -277,3 +277,7 @@ bool WebPage::matchesWindowSelector(QString selector) {
selector == mainFrame()->url().toString() ||
selector == uuid());
}
+
+void WebPage::setFocus() {
+ m_manager->setCurrentPage(this);
+}
View
1 src/WebPage.h
@@ -28,6 +28,7 @@ class WebPage : public QWebPage {
QString uuid();
QString getWindowName();
bool matchesWindowSelector(QString);
+ void setFocus();
public slots:
bool shouldInterruptJavaScript();
View
2 src/WebPageManager.cpp
@@ -3,8 +3,8 @@
#include <stdio.h>
WebPageManager::WebPageManager(QObject *parent) : QObject(parent) {
- m_currentPage = NULL;
m_ignoreSslErrors = false;
+ createPage(this)->setFocus();
}
void WebPageManager::append(WebPage *value) {
View
7 src/WindowFocus.cpp
@@ -4,7 +4,7 @@
#include "CommandFactory.h"
#include "WebPageManager.h"
-WindowFocus::WindowFocus(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+WindowFocus::WindowFocus(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void WindowFocus::start() {
@@ -16,13 +16,12 @@ void WindowFocus::windowNotFound() {
}
void WindowFocus::success(WebPage *page) {
- ((CommandFactory *) parent())->m_manager->setCurrentPage(page);
+ page->setFocus();
emit finished(new Response(true));
}
void WindowFocus::focusWindow(QString selector) {
- QListIterator<WebPage *> pageIterator =
- ((CommandFactory *) parent())->m_manager->iterator();
+ QListIterator<WebPage *> pageIterator = manager()->iterator();
while (pageIterator.hasNext()) {
WebPage *page = pageIterator.next();
View
4 src/WindowFocus.h
@@ -1,12 +1,10 @@
#include "Command.h"
-class WebPage;
-
class WindowFocus : public Command {
Q_OBJECT
public:
- WindowFocus(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ WindowFocus(WebPageManager *, QStringList &arguments, QObject *parent = 0);
virtual void start();
private:
View
3 src/body.cpp
@@ -1,7 +1,8 @@
#include "Body.h"
#include "WebPage.h"
+#include "WebPageManager.h"
-Body::Body(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
+Body::Body(WebPageManager *manager, QStringList &arguments, QObject *parent) : Command(manager, arguments, parent) {
}
void Body::start() {
View
3 src/find_command.h
@@ -1,6 +1,6 @@
#define CHECK_COMMAND(expectedName) \
if (strcmp(#expectedName, name) == 0) { \
- return new expectedName(currentPage(), arguments, this); \
+ return new expectedName(m_manager, arguments, this); \
}
CHECK_COMMAND(Visit)
@@ -20,7 +20,6 @@ CHECK_COMMAND(Headers)
CHECK_COMMAND(SetCookie)
CHECK_COMMAND(ClearCookies)
CHECK_COMMAND(GetCookies)
-CHECK_COMMAND(Headers)
CHECK_COMMAND(SetProxy)
CHECK_COMMAND(ConsoleMessages)
CHECK_COMMAND(RequestedUrl)

0 comments on commit f80125e

Please sign in to comment.