| 1 |
#include "mainqmlview.h" |
| 2 |
#include "qquickrootsrenderer.h" |
| 3 |
#include <QQmlEngine> |
| 4 |
#include <QtQml> |
| 5 |
|
| 6 |
namespace xmpsolve { |
| 7 |
|
| 8 |
MainQmlView::MainQmlView() |
| 9 |
{ |
| 10 |
m_rootContext = rootContext(); |
| 11 |
m_model = m_solver.rootsModel(); |
| 12 |
inflateObjects(); |
| 13 |
loadTypes(); |
| 14 |
|
| 15 |
load(QUrl("qrc:/qml/Main.qml")); |
| 16 |
} |
| 17 |
|
| 18 |
void |
| 19 |
MainQmlView::loadTypes() |
| 20 |
{ |
| 21 |
qmlRegisterType<QQuickRootsRenderer>("MPSolve", 1, 0, "QQuickRootsRenderer"); |
| 22 |
} |
| 23 |
|
| 24 |
void |
| 25 |
MainQmlView::inflateObjects() |
| 26 |
{ |
| 27 |
QQmlContext *ctx = m_rootContext; |
| 28 |
|
| 29 |
ctx->setContextProperty("rootsModel", m_model); |
| 30 |
ctx->setContextProperty("solver", &m_solver); |
| 31 |
|
| 32 |
// Set some other cosmetic values |
| 33 |
ctx->setContextProperty("PACKAGE_STRING", PACKAGE_STRING); |
| 34 |
} |
| 35 |
|
| 36 |
} // namespace xmpsolve |