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/19 22:54:55 UTC
incubator-corinthia git commit: cleaned up editor Qt implementation
classes
Repository: incubator-corinthia
Updated Branches:
refs/heads/master 9f851a342 -> fb5967724
cleaned up editor Qt implementation classes
Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/fb596772
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/fb596772
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/fb596772
Branch: refs/heads/master
Commit: fb596772452c923536c1b307c3bb0eebc6284dbe
Parents: 9f851a3
Author: jani <ja...@apache.org>
Authored: Wed Aug 19 22:54:34 2015 +0200
Committer: jani <ja...@apache.org>
Committed: Wed Aug 19 22:54:34 2015 +0200
----------------------------------------------------------------------
.../src/Toolkit_Layer_1/qt/MainWindow.cpp | 86 +--------
.../src/Toolkit_Layer_1/qt/Toolbar.cpp | 12 +-
.../src/Toolkit_Layer_1/qt/moc_qt_classes.cpp | 188 ++++++-------------
.../src/Toolkit_Layer_1/qt/qt_classes.hpp | 85 ++++-----
.../src/Toolkit_Layer_1/qt/qt_toolkit.cpp | 6 +-
5 files changed, 112 insertions(+), 265 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/fb596772/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
index ab5f994..f31cb0c 100644
--- a/experiments/editorFramework/src/Toolkit_Layer_1/qt/MainWindow.cpp
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/qt/MainWindow.cpp
@@ -20,85 +20,11 @@
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"
+ editor.setParent(this);
-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);
+ this->setLayout(&vlayout);
+ vlayout.addWidget(&toolbar);
+ vlayout.addWidget(&editor);
+ vlayout.setSpacing(0);
+ vlayout.setContentsMargins(4, 4, 4, 4);
}
-
-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/fb596772/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
index e495a86..052e58e 100644
--- a/experiments/editorFramework/src/Toolkit_Layer_1/qt/Toolbar.cpp
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/qt/Toolbar.cpp
@@ -13,12 +13,18 @@
// 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() {
+ saveButton.setText("Save");
+ saveAsButton.setText("SaveAs");
+ loadButton.setText("Load");
+ this->setLayout(&layout);
+ layout.addWidget(&saveButton);
+ layout.addWidget(&saveAsButton);
+ layout.addWidget(&loadButton);
+ layout.setSpacing(4);
+ layout.setContentsMargins(0, 0, 0, 0);
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/fb596772/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
index efb92e6..be69779 100644
--- a/experiments/editorFramework/src/Toolkit_Layer_1/qt/moc_qt_classes.cpp
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/qt/moc_qt_classes.cpp
@@ -18,93 +18,115 @@
#endif
QT_BEGIN_MOC_NAMESPACE
-struct qt_meta_stringdata_Toolbar_t {
- QByteArrayData data[1];
- char stringdata0[8];
+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_Toolbar_t, stringdata0) + ofs \
+ qptrdiff(offsetof(qt_meta_stringdata_Editor_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
-static const qt_meta_stringdata_Toolbar_t qt_meta_stringdata_Toolbar = {
+static const qt_meta_stringdata_Editor_t qt_meta_stringdata_Editor = {
{
-QT_MOC_LITERAL(0, 0, 7) // "Toolbar"
+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"
},
- "Toolbar"
+ "Editor\0webViewloadFinished\0\0ok"
};
#undef QT_MOC_LITERAL
-static const uint qt_meta_data_Toolbar[] = {
+static const uint qt_meta_data_Editor[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
- 0, 0, // methods
+ 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 Toolbar::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+void Editor::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
- Q_UNUSED(_o);
- Q_UNUSED(_id);
- Q_UNUSED(_c);
- Q_UNUSED(_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 Toolbar::staticMetaObject = {
- { &QWidget::staticMetaObject, qt_meta_stringdata_Toolbar.data,
- qt_meta_data_Toolbar, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
+const QMetaObject Editor::staticMetaObject = {
+ { &QWidget::staticMetaObject, qt_meta_stringdata_Editor.data,
+ qt_meta_data_Editor, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
-const QMetaObject *Toolbar::metaObject() const
+const QMetaObject *Editor::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
-void *Toolbar::qt_metacast(const char *_clname)
+void *Editor::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));
+ if (!strcmp(_clname, qt_meta_stringdata_Editor.stringdata0))
+ return static_cast<void*>(const_cast< Editor*>(this));
return QWidget::qt_metacast(_clname);
}
-int Toolbar::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+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_Cursor_t {
+struct qt_meta_stringdata_Toolbar_t {
QByteArrayData data[1];
- char stringdata0[7];
+ 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_Cursor_t, stringdata0) + ofs \
+ qptrdiff(offsetof(qt_meta_stringdata_Toolbar_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
-static const qt_meta_stringdata_Cursor_t qt_meta_stringdata_Cursor = {
+static const qt_meta_stringdata_Toolbar_t qt_meta_stringdata_Toolbar = {
{
-QT_MOC_LITERAL(0, 0, 6) // "Cursor"
+QT_MOC_LITERAL(0, 0, 7) // "Toolbar"
},
- "Cursor"
+ "Toolbar"
};
#undef QT_MOC_LITERAL
-static const uint qt_meta_data_Cursor[] = {
+static const uint qt_meta_data_Toolbar[] = {
// content:
7, // revision
@@ -120,7 +142,7 @@ static const uint qt_meta_data_Cursor[] = {
0 // eod
};
-void Cursor::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+void Toolbar::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
@@ -128,120 +150,30 @@ void Cursor::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void
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 Toolbar::staticMetaObject = {
+ { &QWidget::staticMetaObject, qt_meta_stringdata_Toolbar.data,
+ qt_meta_data_Toolbar, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
-const QMetaObject *Editor::metaObject() const
+const QMetaObject *Toolbar::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
-void *Editor::qt_metacast(const char *_clname)
+void *Toolbar::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));
+ if (!strcmp(_clname, qt_meta_stringdata_Toolbar.stringdata0))
+ return static_cast<void*>(const_cast< Toolbar*>(this));
return QWidget::qt_metacast(_clname);
}
-int Editor::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+int Toolbar::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 {
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/fb596772/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
index 82bc93c..3d51aa0 100644
--- a/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_classes.hpp
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_classes.hpp
@@ -17,6 +17,9 @@
#pragma once
#include "../toolkit.hpp"
#include <QtWidgets/QWidget>
+#include <QtWidgets/QBoxLayout>
+#include <QtWidgets/QPushbutton>
+
/*
@@ -32,58 +35,15 @@
*/
-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
{
@@ -92,8 +52,7 @@ 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; }
+// JSInterface *js() const { return _js; }
public slots:
void webViewloadFinished(bool ok);
@@ -108,11 +67,10 @@ protected:
private:
QWebView *_webView;
- EditorJSCallbacks *_callbacks;
- EditorJSEvaluator *_evaluator;
- JSInterface *_js;
+// EditorJSCallbacks *_callbacks;
+// EditorJSEvaluator *_evaluator;
+// JSInterface *_js;
bool _selecting;
- Cursor *_cursor;
};
@@ -123,6 +81,29 @@ private:
////////////////////////////////////////////////////////////////////////////////////////////////////
// //
+// Toolbar //
+// //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+class Toolbar : public QWidget
+{
+ Q_OBJECT
+public:
+ // Constructor/Destructor
+ Toolbar();
+ ~Toolbar() {};
+
+
+ // Graphical elements
+ QPushButton saveButton;
+ QPushButton saveAsButton;
+ QPushButton loadButton;
+ QHBoxLayout layout;
+};
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// //
// MainWindow //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -136,8 +117,10 @@ public:
~MainWindow() {};
- Toolbar toolbar;
- Editor editor;
+ // Graphical elements
+ Toolbar toolbar;
+ Editor editor;
+ QVBoxLayout vlayout;
};
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/fb596772/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 e9ad884..c3a2ea4 100644
--- a/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_toolkit.cpp
+++ b/experiments/editorFramework/src/Toolkit_Layer_1/qt/qt_toolkit.cpp
@@ -49,9 +49,9 @@ qt_toolkit::qt_toolkit(toolkit_callback *setCallback, int setDebugLevel) :
}
// 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()));
+ 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()));
}