You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by ja...@apache.org on 2015/08/17 20:57:49 UTC

[1/2] incubator-corinthia git commit: change Qt objects from pointers to class variables.

Repository: incubator-corinthia
Updated Branches:
  refs/heads/master 0d28e4513 -> 59a23100c


change Qt objects from pointers to class variables.

Changing away from pointers, make cleanup significantly easier (automatic), and slightly faster.
Signals from the buttons now terminate in the qt_toolkit (implementation class) so that doing a callback is direct.


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

Branch: refs/heads/master
Commit: 7f9c0e1ad2f03903f55f8a0ba9e34f105d619745
Parents: 9bf02bb
Author: jani <ja...@apache.org>
Authored: Mon Aug 17 20:54:36 2015 +0200
Committer: jani <ja...@apache.org>
Committed: Mon Aug 17 20:54:36 2015 +0200

----------------------------------------------------------------------
 .../src/Toolkit_Layer_1/qt/Editor.cpp           |  32 ++
 .../src/Toolkit_Layer_1/qt/MainWindow.cpp       | 104 +++++
 .../src/Toolkit_Layer_1/qt/Toolbar.cpp          |  24 ++
 .../src/Toolkit_Layer_1/qt/moc_qt_classes.cpp   | 415 +++++++++++++++++++
 .../src/Toolkit_Layer_1/qt/moc_windows.cpp      |  89 ----
 .../src/Toolkit_Layer_1/qt/qt_classes.hpp       | 179 ++++++++
 .../src/Toolkit_Layer_1/qt/qt_toolkit.cpp       |  73 +++-
 .../src/Toolkit_Layer_1/qt/qt_toolkit.hpp       |  54 ---
 .../src/Toolkit_Layer_1/qt/windows.cpp          |  24 --
 .../src/Toolkit_Layer_1/qt/windows.hpp          |  56 ---
 .../src/Toolkit_Layer_1/toolkit.hpp             |  22 +-
 11 files changed, 817 insertions(+), 255 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7f9c0e1a/experiments/editorFramework/src/Toolkit_Layer_1/qt/Editor.cpp
----------------------------------------------------------------------
diff --git a/experiments/editorFramework/src/Toolkit_Layer_1/qt/Editor.cpp b/experiments/editorFramework/src/Toolkit_Layer_1/qt/Editor.cpp
new file mode 100644
index 0000000..2b515ac
--- /dev/null
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/qt/Editor.cpp
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+#include "qt_classes.hpp"
+
+
+void Editor::webViewloadFinished(bool ok) {}
+
+Editor::Editor(QWidget *parent, Qt::WindowFlags f) {}
+Editor::~Editor() {}
+
+
+void Editor::mouseDoubleClickEvent(QMouseEvent *event) {}
+void Editor::mouseMoveEvent(QMouseEvent *event) {}
+void Editor::mousePressEvent(QMouseEvent *event) {}
+void Editor::mouseReleaseEvent(QMouseEvent *event) {}
+void Editor::resizeEvent(QResizeEvent *event) {}
+bool Editor::eventFilter(QObject *obj, QEvent *event) { return true; }

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7f9c0e1a/experiments/editorFramework/src/Toolkit_Layer_1/qt/MainWindow.cpp
----------------------------------------------------------------------
diff --git a/experiments/editorFramework/src/Toolkit_Layer_1/qt/MainWindow.cpp b/experiments/editorFramework/src/Toolkit_Layer_1/qt/MainWindow.cpp
new file mode 100644
index 0000000..ab5f994
--- /dev/null
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/qt/MainWindow.cpp
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+#include "qt_classes.hpp"
+
+
+MainWindow::MainWindow() {
+    toolbar.setParent(this);
+}
+
+
+
+#if 0
+#include "MainWindow.h"
+#include <QWebView>
+#include <QVBoxLayout>
+#include <QPushButton>
+#include <QCoreApplication>
+#include "Editor.h"
+#include "JSInterface.h"
+#include "Toolbar.h"
+
+MainWindow::MainWindow(QApplication *app) : QWidget(0)
+{
+    _app = app;
+    _toolbar = new Toolbar(this);
+    _editor = new Editor(this);
+    QVBoxLayout *vlayout = new QVBoxLayout();
+    this->setLayout(vlayout);
+    vlayout->addWidget(_toolbar);
+    vlayout->addWidget(_editor);
+    vlayout->setSpacing(0);
+    vlayout->setContentsMargins(4, 4, 4, 4);
+
+
+    QString appPath = QCoreApplication::applicationDirPath();
+    QString docPath = appPath + "/../share/corinthia/sample.html";
+    QUrl url = QUrl::fromLocalFile(docPath);
+    qStdOut() << "sample document url = " << url.toString() << endl;
+    _editor->webView()->load(url);
+}
+
+MainWindow::~MainWindow()
+{
+    delete _toolbar;
+    delete _editor;
+}
+
+void MainWindow::insertTable()
+{
+    _editor->js()->tables.insertTable(4, 3, "50%", true, "Table caption", QString::null);
+}
+
+void MainWindow::insertLink()
+{
+    _editor->js()->cursor.insertLink("Corinthia website", "http://corinthia.incubator.apache.org");
+}
+
+void MainWindow::insertCharacter()
+{
+    _editor->js()->cursor.insertCharacter('X', true);
+}
+
+void MainWindow::backspace()
+{
+    _editor->js()->cursor.deleteCharacter();
+}
+
+void MainWindow::moveLeft()
+{
+    _editor->js()->cursor.moveLeft();
+}
+
+void MainWindow::moveRight()
+{
+    _editor->js()->cursor.moveRight();
+}
+
+void MainWindow::undo()
+{
+    _editor->js()->undoManager.undo();
+}
+
+void MainWindow::redo()
+{
+    _editor->js()->undoManager.redo();
+}
+
+//#include <MainWindow.moc>
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7f9c0e1a/experiments/editorFramework/src/Toolkit_Layer_1/qt/Toolbar.cpp
----------------------------------------------------------------------
diff --git a/experiments/editorFramework/src/Toolkit_Layer_1/qt/Toolbar.cpp b/experiments/editorFramework/src/Toolkit_Layer_1/qt/Toolbar.cpp
new file mode 100644
index 0000000..e495a86
--- /dev/null
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/qt/Toolbar.cpp
@@ -0,0 +1,24 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+#include "qt_classes.hpp"
+
+
+Toolbar::Toolbar() {
+}
+Toolbar::~Toolbar() {
+}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7f9c0e1a/experiments/editorFramework/src/Toolkit_Layer_1/qt/moc_qt_classes.cpp
----------------------------------------------------------------------
diff --git a/experiments/editorFramework/src/Toolkit_Layer_1/qt/moc_qt_classes.cpp b/experiments/editorFramework/src/Toolkit_Layer_1/qt/moc_qt_classes.cpp
new file mode 100644
index 0000000..efb92e6
--- /dev/null
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/qt/moc_qt_classes.cpp
@@ -0,0 +1,415 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'qt_classes.hpp'
+**
+** Created by: The Qt Meta Object Compiler version 67 (Qt 5.5.0)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "qt_classes.hpp"
+#include <QtCore/qbytearray.h>
+#include <QtCore/qmetatype.h>
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'qt_classes.hpp' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 67
+#error "This file was generated using the moc from 5.5.0. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+struct qt_meta_stringdata_Toolbar_t {
+    QByteArrayData data[1];
+    char stringdata0[8];
+};
+#define QT_MOC_LITERAL(idx, ofs, len) \
+    Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
+    qptrdiff(offsetof(qt_meta_stringdata_Toolbar_t, stringdata0) + ofs \
+        - idx * sizeof(QByteArrayData)) \
+    )
+static const qt_meta_stringdata_Toolbar_t qt_meta_stringdata_Toolbar = {
+    {
+QT_MOC_LITERAL(0, 0, 7) // "Toolbar"
+
+    },
+    "Toolbar"
+};
+#undef QT_MOC_LITERAL
+
+static const uint qt_meta_data_Toolbar[] = {
+
+ // content:
+       7,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       0,    0, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+       0,    0, // constructors
+       0,       // flags
+       0,       // signalCount
+
+       0        // eod
+};
+
+void Toolbar::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+    Q_UNUSED(_o);
+    Q_UNUSED(_id);
+    Q_UNUSED(_c);
+    Q_UNUSED(_a);
+}
+
+const QMetaObject Toolbar::staticMetaObject = {
+    { &QWidget::staticMetaObject, qt_meta_stringdata_Toolbar.data,
+      qt_meta_data_Toolbar,  qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
+};
+
+
+const QMetaObject *Toolbar::metaObject() const
+{
+    return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
+}
+
+void *Toolbar::qt_metacast(const char *_clname)
+{
+    if (!_clname) return Q_NULLPTR;
+    if (!strcmp(_clname, qt_meta_stringdata_Toolbar.stringdata0))
+        return static_cast<void*>(const_cast< Toolbar*>(this));
+    return QWidget::qt_metacast(_clname);
+}
+
+int Toolbar::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QWidget::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    return _id;
+}
+struct qt_meta_stringdata_Cursor_t {
+    QByteArrayData data[1];
+    char stringdata0[7];
+};
+#define QT_MOC_LITERAL(idx, ofs, len) \
+    Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
+    qptrdiff(offsetof(qt_meta_stringdata_Cursor_t, stringdata0) + ofs \
+        - idx * sizeof(QByteArrayData)) \
+    )
+static const qt_meta_stringdata_Cursor_t qt_meta_stringdata_Cursor = {
+    {
+QT_MOC_LITERAL(0, 0, 6) // "Cursor"
+
+    },
+    "Cursor"
+};
+#undef QT_MOC_LITERAL
+
+static const uint qt_meta_data_Cursor[] = {
+
+ // content:
+       7,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       0,    0, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+       0,    0, // constructors
+       0,       // flags
+       0,       // signalCount
+
+       0        // eod
+};
+
+void Cursor::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+    Q_UNUSED(_o);
+    Q_UNUSED(_id);
+    Q_UNUSED(_c);
+    Q_UNUSED(_a);
+}
+
+const QMetaObject Cursor::staticMetaObject = {
+    { &QWidget::staticMetaObject, qt_meta_stringdata_Cursor.data,
+      qt_meta_data_Cursor,  qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
+};
+
+
+const QMetaObject *Cursor::metaObject() const
+{
+    return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
+}
+
+void *Cursor::qt_metacast(const char *_clname)
+{
+    if (!_clname) return Q_NULLPTR;
+    if (!strcmp(_clname, qt_meta_stringdata_Cursor.stringdata0))
+        return static_cast<void*>(const_cast< Cursor*>(this));
+    return QWidget::qt_metacast(_clname);
+}
+
+int Cursor::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QWidget::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    return _id;
+}
+struct qt_meta_stringdata_Editor_t {
+    QByteArrayData data[4];
+    char stringdata0[31];
+};
+#define QT_MOC_LITERAL(idx, ofs, len) \
+    Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
+    qptrdiff(offsetof(qt_meta_stringdata_Editor_t, stringdata0) + ofs \
+        - idx * sizeof(QByteArrayData)) \
+    )
+static const qt_meta_stringdata_Editor_t qt_meta_stringdata_Editor = {
+    {
+QT_MOC_LITERAL(0, 0, 6), // "Editor"
+QT_MOC_LITERAL(1, 7, 19), // "webViewloadFinished"
+QT_MOC_LITERAL(2, 27, 0), // ""
+QT_MOC_LITERAL(3, 28, 2) // "ok"
+
+    },
+    "Editor\0webViewloadFinished\0\0ok"
+};
+#undef QT_MOC_LITERAL
+
+static const uint qt_meta_data_Editor[] = {
+
+ // content:
+       7,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       1,   14, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+       0,    0, // constructors
+       0,       // flags
+       0,       // signalCount
+
+ // slots: name, argc, parameters, tag, flags
+       1,    1,   19,    2, 0x0a /* Public */,
+
+ // slots: parameters
+    QMetaType::Void, QMetaType::Bool,    3,
+
+       0        // eod
+};
+
+void Editor::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        Editor *_t = static_cast<Editor *>(_o);
+        Q_UNUSED(_t)
+        switch (_id) {
+        case 0: _t->webViewloadFinished((*reinterpret_cast< bool(*)>(_a[1]))); break;
+        default: ;
+        }
+    }
+}
+
+const QMetaObject Editor::staticMetaObject = {
+    { &QWidget::staticMetaObject, qt_meta_stringdata_Editor.data,
+      qt_meta_data_Editor,  qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
+};
+
+
+const QMetaObject *Editor::metaObject() const
+{
+    return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
+}
+
+void *Editor::qt_metacast(const char *_clname)
+{
+    if (!_clname) return Q_NULLPTR;
+    if (!strcmp(_clname, qt_meta_stringdata_Editor.stringdata0))
+        return static_cast<void*>(const_cast< Editor*>(this));
+    return QWidget::qt_metacast(_clname);
+}
+
+int Editor::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QWidget::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        if (_id < 1)
+            qt_static_metacall(this, _c, _id, _a);
+        _id -= 1;
+    } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
+        if (_id < 1)
+            *reinterpret_cast<int*>(_a[0]) = -1;
+        _id -= 1;
+    }
+    return _id;
+}
+struct qt_meta_stringdata_MainWindow_t {
+    QByteArrayData data[1];
+    char stringdata0[11];
+};
+#define QT_MOC_LITERAL(idx, ofs, len) \
+    Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
+    qptrdiff(offsetof(qt_meta_stringdata_MainWindow_t, stringdata0) + ofs \
+        - idx * sizeof(QByteArrayData)) \
+    )
+static const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = {
+    {
+QT_MOC_LITERAL(0, 0, 10) // "MainWindow"
+
+    },
+    "MainWindow"
+};
+#undef QT_MOC_LITERAL
+
+static const uint qt_meta_data_MainWindow[] = {
+
+ // content:
+       7,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       0,    0, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+       0,    0, // constructors
+       0,       // flags
+       0,       // signalCount
+
+       0        // eod
+};
+
+void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+    Q_UNUSED(_o);
+    Q_UNUSED(_id);
+    Q_UNUSED(_c);
+    Q_UNUSED(_a);
+}
+
+const QMetaObject MainWindow::staticMetaObject = {
+    { &QWidget::staticMetaObject, qt_meta_stringdata_MainWindow.data,
+      qt_meta_data_MainWindow,  qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
+};
+
+
+const QMetaObject *MainWindow::metaObject() const
+{
+    return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
+}
+
+void *MainWindow::qt_metacast(const char *_clname)
+{
+    if (!_clname) return Q_NULLPTR;
+    if (!strcmp(_clname, qt_meta_stringdata_MainWindow.stringdata0))
+        return static_cast<void*>(const_cast< MainWindow*>(this));
+    return QWidget::qt_metacast(_clname);
+}
+
+int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QWidget::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    return _id;
+}
+struct qt_meta_stringdata_qt_toolkit_t {
+    QByteArrayData data[5];
+    char stringdata0[29];
+};
+#define QT_MOC_LITERAL(idx, ofs, len) \
+    Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
+    qptrdiff(offsetof(qt_meta_stringdata_qt_toolkit_t, stringdata0) + ofs \
+        - idx * sizeof(QByteArrayData)) \
+    )
+static const qt_meta_stringdata_qt_toolkit_t qt_meta_stringdata_qt_toolkit = {
+    {
+QT_MOC_LITERAL(0, 0, 10), // "qt_toolkit"
+QT_MOC_LITERAL(1, 11, 4), // "save"
+QT_MOC_LITERAL(2, 16, 0), // ""
+QT_MOC_LITERAL(3, 17, 6), // "saveAs"
+QT_MOC_LITERAL(4, 24, 4) // "load"
+
+    },
+    "qt_toolkit\0save\0\0saveAs\0load"
+};
+#undef QT_MOC_LITERAL
+
+static const uint qt_meta_data_qt_toolkit[] = {
+
+ // content:
+       7,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       3,   14, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+       0,    0, // constructors
+       0,       // flags
+       0,       // signalCount
+
+ // slots: name, argc, parameters, tag, flags
+       1,    0,   29,    2, 0x0a /* Public */,
+       3,    0,   30,    2, 0x0a /* Public */,
+       4,    0,   31,    2, 0x0a /* Public */,
+
+ // slots: parameters
+    QMetaType::Void,
+    QMetaType::Void,
+    QMetaType::Void,
+
+       0        // eod
+};
+
+void qt_toolkit::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        qt_toolkit *_t = static_cast<qt_toolkit *>(_o);
+        Q_UNUSED(_t)
+        switch (_id) {
+        case 0: _t->save(); break;
+        case 1: _t->saveAs(); break;
+        case 2: _t->load(); break;
+        default: ;
+        }
+    }
+    Q_UNUSED(_a);
+}
+
+const QMetaObject qt_toolkit::staticMetaObject = {
+    { &QObject::staticMetaObject, qt_meta_stringdata_qt_toolkit.data,
+      qt_meta_data_qt_toolkit,  qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
+};
+
+
+const QMetaObject *qt_toolkit::metaObject() const
+{
+    return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
+}
+
+void *qt_toolkit::qt_metacast(const char *_clname)
+{
+    if (!_clname) return Q_NULLPTR;
+    if (!strcmp(_clname, qt_meta_stringdata_qt_toolkit.stringdata0))
+        return static_cast<void*>(const_cast< qt_toolkit*>(this));
+    if (!strcmp(_clname, "toolkit"))
+        return static_cast< toolkit*>(const_cast< qt_toolkit*>(this));
+    return QObject::qt_metacast(_clname);
+}
+
+int qt_toolkit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QObject::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        if (_id < 3)
+            qt_static_metacall(this, _c, _id, _a);
+        _id -= 3;
+    } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
+        if (_id < 3)
+            *reinterpret_cast<int*>(_a[0]) = -1;
+        _id -= 3;
+    }
+    return _id;
+}
+QT_END_MOC_NAMESPACE

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7f9c0e1a/experiments/editorFramework/src/Toolkit_Layer_1/qt/moc_windows.cpp
----------------------------------------------------------------------
diff --git a/experiments/editorFramework/src/Toolkit_Layer_1/qt/moc_windows.cpp b/experiments/editorFramework/src/Toolkit_Layer_1/qt/moc_windows.cpp
deleted file mode 100644
index a7022d6..0000000
--- a/experiments/editorFramework/src/Toolkit_Layer_1/qt/moc_windows.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-** Meta object code from reading C++ file 'windows.hpp'
-**
-** Created by: The Qt Meta Object Compiler version 67 (Qt 5.5.0)
-**
-** WARNING! All changes made in this file will be lost!
-*****************************************************************************/
-
-#include "windows.hpp"
-#include <QtCore/qbytearray.h>
-#include <QtCore/qmetatype.h>
-#if !defined(Q_MOC_OUTPUT_REVISION)
-#error "The header file 'windows.hpp' doesn't include <QObject>."
-#elif Q_MOC_OUTPUT_REVISION != 67
-#error "This file was generated using the moc from 5.5.0. It"
-#error "cannot be used with the include files from this version of Qt."
-#error "(The moc has changed too much.)"
-#endif
-
-QT_BEGIN_MOC_NAMESPACE
-struct qt_meta_stringdata_MainWindow_t {
-    QByteArrayData data[1];
-    char stringdata0[11];
-};
-#define QT_MOC_LITERAL(idx, ofs, len) \
-    Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
-    qptrdiff(offsetof(qt_meta_stringdata_MainWindow_t, stringdata0) + ofs \
-        - idx * sizeof(QByteArrayData)) \
-    )
-static const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = {
-    {
-QT_MOC_LITERAL(0, 0, 10) // "MainWindow"
-
-    },
-    "MainWindow"
-};
-#undef QT_MOC_LITERAL
-
-static const uint qt_meta_data_MainWindow[] = {
-
- // content:
-       7,       // revision
-       0,       // classname
-       0,    0, // classinfo
-       0,    0, // methods
-       0,    0, // properties
-       0,    0, // enums/sets
-       0,    0, // constructors
-       0,       // flags
-       0,       // signalCount
-
-       0        // eod
-};
-
-void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
-{
-    Q_UNUSED(_o);
-    Q_UNUSED(_id);
-    Q_UNUSED(_c);
-    Q_UNUSED(_a);
-}
-
-const QMetaObject MainWindow::staticMetaObject = {
-    { &QWidget::staticMetaObject, qt_meta_stringdata_MainWindow.data,
-      qt_meta_data_MainWindow,  qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
-};
-
-
-const QMetaObject *MainWindow::metaObject() const
-{
-    return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
-}
-
-void *MainWindow::qt_metacast(const char *_clname)
-{
-    if (!_clname) return Q_NULLPTR;
-    if (!strcmp(_clname, qt_meta_stringdata_MainWindow.stringdata0))
-        return static_cast<void*>(const_cast< MainWindow*>(this));
-    return QWidget::qt_metacast(_clname);
-}
-
-int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
-{
-    _id = QWidget::qt_metacall(_c, _id, _a);
-    if (_id < 0)
-        return _id;
-    return _id;
-}
-QT_END_MOC_NAMESPACE

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7f9c0e1a/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_classes.hpp
----------------------------------------------------------------------
diff --git a/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_classes.hpp b/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_classes.hpp
new file mode 100644
index 0000000..82bc93c
--- /dev/null
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_classes.hpp
@@ -0,0 +1,179 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+#pragma once
+#include "../toolkit.hpp"
+#include <QtWidgets/QWidget>
+
+
+/*
+ * qt_classes.hpp all the graphical classes inherited from Qt
+ * Typically each class would have its own header file, but that
+ * would also mean 1 MOC file pr class. Having all Qt definitions
+ * in 1 files gives a couple of advantages
+ * - only a single moc_qt_classes.cpp file
+ * - All qt definitions in one file makes the overview easier
+ *
+ * The current graphical layout will change once we get a graphical 
+ * designer to take a look.
+ */
+
+
+class QPushButton;
+class QHBoxLayout;
+
+class Toolbar : public QWidget
+{
+    Q_OBJECT
+public:
+    Toolbar();
+    virtual ~Toolbar();
+
+    QPushButton *saveButton;
+    QPushButton *saveAsButton;
+    QPushButton *loadButton;
+    QHBoxLayout *_layout;
+};
+
+
+
+
+
+
+
+
+
+class Editor;
+class EditorJSEvaluator;
+class QWebView;
+class JSInterface;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                             Cursor                                             //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class Cursor : public QWidget
+{
+    Q_OBJECT
+public:
+    Cursor(QWidget *parent = 0);
+    virtual ~Cursor();
+
+protected:
+    virtual void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                             Editor                                             //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+class EditorJSCallbacks;
+
+class Editor : public QWidget
+{
+    Q_OBJECT
+public:
+    Editor(QWidget *parent = 0, Qt::WindowFlags f = 0);
+    virtual ~Editor();
+    QWebView *webView() const { return _webView; }
+    JSInterface *js() const { return _js; }
+    Cursor *cursor() const { return _cursor; }
+
+    public slots:
+    void webViewloadFinished(bool ok);
+
+protected:
+    virtual void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+    virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+    virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+    virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+    virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
+    virtual bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
+
+private:
+    QWebView *_webView;
+    EditorJSCallbacks *_callbacks;
+    EditorJSEvaluator *_evaluator;
+    JSInterface *_js;
+    bool _selecting;
+    Cursor *_cursor;
+};
+
+
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                           MainWindow                                           //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+class MainWindow : public QWidget
+{
+    /* Main window, this adds all other widgets inside */
+    Q_OBJECT
+public:
+    // Constructor/Destructor
+    MainWindow();
+    ~MainWindow() {};
+
+
+    Toolbar toolbar;
+    Editor  editor;
+};
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                           qt_toolkit                                           //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+class qt_toolkit : QObject, toolkit
+{
+    /* toolkit qt implementation */
+    Q_OBJECT
+
+
+public:
+    // Constructor/Destructor
+    qt_toolkit(toolkit_callback *setCallback, int setDebugLevel);
+    ~qt_toolkit() {};
+
+
+    // Inherited functions (accessible from the generic layer
+    bool startWindow();
+    void run();
+    bool callJavascript(const char *function);
+
+
+public slots:
+    void save();
+    void saveAs();
+    void load();
+
+ 
+private:
+    static QApplication *app;
+    MainWindow           window;
+    toolkit_callback    *callback;
+    int                  debugLevel;
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7f9c0e1a/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_toolkit.cpp
----------------------------------------------------------------------
diff --git a/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_toolkit.cpp b/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_toolkit.cpp
index 0599b8f..e9ad884 100644
--- a/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_toolkit.cpp
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_toolkit.cpp
@@ -13,31 +13,47 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-
 #pragma once
-#include "windows.hpp"
-#include "qt_toolkit.hpp"
+#include <QtWidgets/QApplication>
+#include "qt_classes.hpp"
 
 
+/*
+ * Implementation of
+ * Interface between implementation dependent toolkit and the API available for the handling.
+ *
+ * This file implements the smallest possible interface, in order to facilitate easier
+ * implementation of other toolkits.
+ *
+ * The Callbacks are handled through the signal/post function of Qt.
+ *
+ */
 
-// Constructor/Destructor
-qt_toolkit::qt_toolkit(toolkit_callback *setCallback, int setDebugLevel) {
-    int    argc = 0;
-    char **argv = NULL;
 
 
-    callback   = setCallback;
-    debugLevel = setDebugLevel;
-    app        = new QApplication(argc, argv);
-}
-qt_toolkit::~qt_toolkit() {
-    if (window)
-        delete window;
-    if (app)
-        delete app;
-}
+// Static Variables
+QApplication * qt_toolkit::app;
+
 
 
+// Constructor/Destructor
+qt_toolkit::qt_toolkit(toolkit_callback *setCallback, int setDebugLevel) :
+    callback(setCallback),
+    debugLevel(setDebugLevel)
+{
+    // Application is only added once 
+    if (!app) {
+        int    argc = 0;
+        char **argv = NULL;
+        app         = new QApplication(argc, argv);
+    }
+
+    // get notification, when user click on button
+    QObject::connect((const QObject *)window.toolbar.saveButton, SIGNAL(clicked()), this, SLOT(saveButton()));
+    QObject::connect((const QObject *)window.toolbar.saveAsButton, SIGNAL(clicked()), this, SLOT(saveAsButton()));
+    QObject::connect((const QObject *)window.toolbar.loadButton, SIGNAL(clicked()), this, SLOT(saveAsButton()));
+}
+
 
 // Instanciate the derived class.
 toolkit * toolkit::createInstance(toolkit_callback *tk, int setDebugLevel) {
@@ -45,24 +61,35 @@ toolkit * toolkit::createInstance(toolkit_callback *tk, int setDebugLevel) {
 }
 
 
-
-// Prepare graphic
+// Prepare graphic (not used in the Qt implementation)
 bool qt_toolkit::startWindow() {
-    window = new MainWindow(app);
     return true;
 }
 
 
-
 // Sart message loop, and to not return
 void qt_toolkit::run() {
-    window->show();
+    window.show();
     app->exec();
 }
 
 
-
 // Activate Javascript function
 bool qt_toolkit::callJavascript(const char *function) {
     return true;
 }
+
+
+// Notify save was requested
+void qt_toolkit::save() {
+}
+
+
+// Notify saveAs was requested
+void qt_toolkit::saveAs() {
+}
+
+
+// Notify load was requested
+void qt_toolkit::load() {
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7f9c0e1a/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_toolkit.hpp
----------------------------------------------------------------------
diff --git a/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_toolkit.hpp b/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_toolkit.hpp
deleted file mode 100644
index 6603e41..0000000
--- a/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_toolkit.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-#pragma once
-#include "../toolkit.hpp"
-#include <QtWidgets/QApplication>
-
-
-
-/*
- * Implementation of toolkit generic interface in Qt
- *
- */
-
-
-
-class qt_toolkit : toolkit
-{
-    /* toolkit qt implementation */
-
-public:
-    /* Inherited functions */
-    bool startWindow();
-    void run();
-    bool callJavascript(const char *function);
-
-
-
-    // Constructor/Destructor
-    qt_toolkit(toolkit_callback *setCallback, int setDebugLevel);
-    ~qt_toolkit();
-
-
-
-private: 
-    QApplication     *app;
-    MainWindow       *window;
-    toolkit_callback *callback;
-    int               debugLevel;
-};
-

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7f9c0e1a/experiments/editorFramework/src/Toolkit_Layer_1/qt/windows.cpp
----------------------------------------------------------------------
diff --git a/experiments/editorFramework/src/Toolkit_Layer_1/qt/windows.cpp b/experiments/editorFramework/src/Toolkit_Layer_1/qt/windows.cpp
deleted file mode 100644
index 57a9686..0000000
--- a/experiments/editorFramework/src/Toolkit_Layer_1/qt/windows.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#pragma once
-#include "windows.hpp"
-
-
-MainWindow::MainWindow(QApplication *app) {
-}
-MainWindow::~MainWindow() {
-}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7f9c0e1a/experiments/editorFramework/src/Toolkit_Layer_1/qt/windows.hpp
----------------------------------------------------------------------
diff --git a/experiments/editorFramework/src/Toolkit_Layer_1/qt/windows.hpp b/experiments/editorFramework/src/Toolkit_Layer_1/qt/windows.hpp
deleted file mode 100644
index 07d6eff..0000000
--- a/experiments/editorFramework/src/Toolkit_Layer_1/qt/windows.hpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-#pragma once
-#include <QtWidgets/QWidget>
-
-
-
-/******************** WINDOWS.HPP ********************
- * This file contain all the graphical classes 
- * inherited from Qt
- */
-
-
-
-// Main window, this adds all other widgets inside
-class MainWindow : public QWidget
-{
-    Q_OBJECT
-public:
-    MainWindow(QApplication *app);
-    ~MainWindow();
-
-
-    
-public slots:
-/*
-    void insertTable();
-    void insertLink();
-    void insertCharacter();
-    void backspace();
-    void moveLeft();
-    void moveRight();
-    void undo();
-    void redo();
- */
-
-
-private:
-    QApplication *_app;
-//    Toolbar *_toolbar;
-//    Editor *_editor;
-};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7f9c0e1a/experiments/editorFramework/src/Toolkit_Layer_1/toolkit.hpp
----------------------------------------------------------------------
diff --git a/experiments/editorFramework/src/Toolkit_Layer_1/toolkit.hpp b/experiments/editorFramework/src/Toolkit_Layer_1/toolkit.hpp
index 374c743..2420eb9 100644
--- a/experiments/editorFramework/src/Toolkit_Layer_1/toolkit.hpp
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/toolkit.hpp
@@ -17,7 +17,6 @@
 #pragma once
 
 
-
 /*
  * Interface between implementation dependent toolkit and the API available for the handling.
  *
@@ -50,6 +49,11 @@
 
 
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                        toolkit_callback                                        //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
 class toolkit_callback {
     /* Callback interface
      *
@@ -74,19 +78,16 @@ public:
     virtual void debug(int level, const char *message) = 0;
 
 
-
     // pass back Javascript result
     virtual void notifyJavascript(const char *message) = 0;
 
 
-
     // pass back Button action
     // button can have values as defined in toolkit class
     // (note windows actions are handled as special buttons)
     virtual void notifyButtonPressed(int button) = 0;
 
 
-
     // pass back Dialogbox action
     // dialog can have values as defined in toolkit class
     virtual void notifyDialog(int dialog, const char *message) = 0;
@@ -94,9 +95,14 @@ public:
 
 
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                            toolkit                                             //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
 class toolkit
 {
-    /* toolkit interface
+    /* Toolkit interface
     *
     * this class is pure virtual, to make sure it gets implemented in toolkit implementation without any dependencies
     * from the generic layer.
@@ -104,8 +110,10 @@ class toolkit
     * Methods in this class activate graphical functions
     *
     * A static createInstance() is supplied to allow the TK implementation to instanciate the derived class
+    *
     */
 
+
 public:
     // Enumeration for DEBUG level
     static const enum {
@@ -117,23 +125,19 @@ public:
     };
 
 
-
     // Function to create a new instance, this is needed to allow the implementation class
     // to have a derived class that contain implementation dependent functions and variables
     static toolkit *createInstance(toolkit_callback *callback, int setDebugLevel);
 
 
-
     // Start windows etc
     virtual bool startWindow() = 0;
 
 
-
     // Start message loop, does not return, unless main window is terminated
     virtual void run() = 0;
 
 
-
     // Start Javascript
     virtual bool callJavascript(const char *function) = 0;
 };



[2/2] incubator-corinthia git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-corinthia

Posted by ja...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-corinthia


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

Branch: refs/heads/master
Commit: 59a23100c00a83375a3fe0626f0462254b4b8f14
Parents: 7f9c0e1 0d28e45
Author: jani <ja...@apache.org>
Authored: Mon Aug 17 20:57:25 2015 +0200
Committer: jani <ja...@apache.org>
Committed: Mon Aug 17 20:57:25 2015 +0200

----------------------------------------------------------------------
 README.md                |   2 +-
 THANKS                   |   2 +-
 tree_git_repository.html | 213 ------------------------------------------
 3 files changed, 2 insertions(+), 215 deletions(-)
----------------------------------------------------------------------