corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmke...@apache.org
Subject incubator-corinthia git commit: Merge EditorPrivate class into Editor
Date Sat, 06 Jun 2015 23:31:56 GMT
Repository: incubator-corinthia
Updated Branches:
  refs/heads/master 601bc5e65 -> 7257fdef0


Merge EditorPrivate class into Editor

The Editor class, as exposed publicly, hid most of its details in a
separate EditorPrivate class defined inside Editor.cpp. There's going to
be a *lot* of work done on the Editor class in the near future, and I
expect there'll be need to access some of the properties/methods from
other files, so I've merged the two classes together for now.

It's a common idiom in Qt to have a separate private class for details
that you don't want exposed generally, and we'll likely want this for
Editor in the future, but it's more convenient to have it all in the one
class for now.


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/7257fdef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/7257fdef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/7257fdef

Branch: refs/heads/master
Commit: 7257fdef093a0798fcff20a12322832dd670a484
Parents: 601bc5e
Author: Peter Kelly <peter@uxproductivity.com>
Authored: Sun Jun 7 06:29:30 2015 +0700
Committer: Peter Kelly <peter@uxproductivity.com>
Committed: Sun Jun 7 06:29:30 2015 +0700

----------------------------------------------------------------------
 consumers/corinthia/src/Editor.cpp    | 67 +++++++++---------------------
 consumers/corinthia/src/Editor.h      | 12 +++++-
 consumers/corinthia/src/JSInterface.h |  2 +-
 3 files changed, 31 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7257fdef/consumers/corinthia/src/Editor.cpp
----------------------------------------------------------------------
diff --git a/consumers/corinthia/src/Editor.cpp b/consumers/corinthia/src/Editor.cpp
index 94d9fe0..165df1d 100644
--- a/consumers/corinthia/src/Editor.cpp
+++ b/consumers/corinthia/src/Editor.cpp
@@ -57,23 +57,6 @@ private:
     JSCallbacks *_callbacks;
 };
 
-class EditorPrivate : public QObject
-{
-    Q_OBJECT
-public:
-    EditorPrivate(Editor *editor);
-    virtual ~EditorPrivate();
-    public slots:
-    void webViewloadFinished(bool ok);
-public:
-
-    Editor *_editor;
-    QWebView *_webView;
-    EditorJSCallbacks *_callbacks;
-    EditorJSEvaluator *_evaluator;
-    JSInterface *_js;
-};
-
 
 
 const char *jsSources[] = {
@@ -221,16 +204,19 @@ QString EditorJSEvaluator::evaluate(const QString &script)
 
 
 
-EditorPrivate::EditorPrivate(Editor *editor) : _editor(editor)
+Editor::Editor(QWidget *parent, Qt::WindowFlags f) : QWidget(parent,f)
 {
-    _webView = new QWebView(editor);
-    _callbacks = new EditorJSCallbacks(editor);
+    _webView = new QWebView(this);
+    _callbacks = new EditorJSCallbacks(this);
     _evaluator = new EditorJSEvaluator(_webView,_callbacks);
     _js = new JSInterface(_evaluator);
     QObject::connect(_webView,SIGNAL(loadFinished(bool)),this,SLOT(webViewloadFinished(bool)));
+    QVBoxLayout *layout = new QVBoxLayout(this);
+    layout->addWidget(_webView);
+    setLayout(layout);
 }
 
-EditorPrivate::~EditorPrivate()
+Editor::~Editor()
 {
     delete _webView;
     delete _callbacks;
@@ -238,13 +224,23 @@ EditorPrivate::~EditorPrivate()
     delete _js;
 }
 
-void EditorPrivate::webViewloadFinished(bool ok)
+QWebView *Editor::webView() const
+{
+    return _webView;
+}
+
+JSInterface *Editor::js() const
+{
+    return _js;
+}
+
+void Editor::webViewloadFinished(bool ok)
 {
     qStdOut() << "webViewloadFinished: ok = " << ok << endl;
     if (!ok)
         return;
-    QWebFrame *frame = _editor->webView()->page()->mainFrame();
-    //    frame->evaluateJavaScript("alert('This is a test')");
+    QWebFrame *frame = _webView->page()->mainFrame();
+//    frame->evaluateJavaScript("alert('This is a test')");
 
     QString appPath = QCoreApplication::applicationDirPath();
     QString baseDir = appPath + "/../share/corinthia/js";
@@ -270,27 +266,4 @@ void EditorPrivate::webViewloadFinished(bool ok)
     processCallbacks(_evaluator);
 }
 
-Editor::Editor(QWidget *parent, Qt::WindowFlags f) : QWidget(parent,f)
-{
-    _p = new EditorPrivate(this);
-    QVBoxLayout *layout = new QVBoxLayout(this);
-    layout->addWidget(_p->_webView);
-    setLayout(layout);
-}
-
-Editor::~Editor()
-{
-    delete _p;
-}
-
-QWebView *Editor::webView() const
-{
-    return _p->_webView;
-}
-
-JSInterface *Editor::js() const
-{
-    return _p->_js;
-}
-
 #include <Editor.moc>

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7257fdef/consumers/corinthia/src/Editor.h
----------------------------------------------------------------------
diff --git a/consumers/corinthia/src/Editor.h b/consumers/corinthia/src/Editor.h
index 94ec4a7..d077ee4 100644
--- a/consumers/corinthia/src/Editor.h
+++ b/consumers/corinthia/src/Editor.h
@@ -18,7 +18,8 @@
 #include <QWidget>
 
 class Editor;
-class EditorPrivate;
+class EditorJSCallbacks;
+class EditorJSEvaluator;
 class QWebView;
 class JSInterface;
 
@@ -30,6 +31,13 @@ public:
     virtual ~Editor();
     QWebView *webView() const;
     JSInterface *js() const;
+
+public slots:
+    void webViewloadFinished(bool ok);
+
 private:
-    EditorPrivate *_p;
+    QWebView *_webView;
+    EditorJSCallbacks *_callbacks;
+    EditorJSEvaluator *_evaluator;
+    JSInterface *_js;
 };

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7257fdef/consumers/corinthia/src/JSInterface.h
----------------------------------------------------------------------
diff --git a/consumers/corinthia/src/JSInterface.h b/consumers/corinthia/src/JSInterface.h
index 8cb9e85..938e88e 100644
--- a/consumers/corinthia/src/JSInterface.h
+++ b/consumers/corinthia/src/JSInterface.h
@@ -109,7 +109,7 @@ public:
  * the application, in that it provides the necessary access to call *in* to javascript,
and to
  * respond (via callbacks) to calls *out* of javascript. Upon initialisation of a document
window,
  * concrete implementations of both JSCallbacks and JSEvaluator are created, the latter maintaining
- * a reference to the former. See EditorPrivate::EditorPrivate() for where ths is actually
done.
+ * a reference to the former. See Editor::Editor() for where ths is actually done.
  */
 class JSEvaluator
 {


Mime
View raw message