diff --git a/rust-qt-binding-generator b/rust-qt-binding-generator index 598336e..8a37b35 160000 --- a/rust-qt-binding-generator +++ b/rust-qt-binding-generator @@ -1 +1 @@ -Subproject commit 598336e657cb4bf5ef5070dfa35b999b7dfd341b +Subproject commit 8a37b359ca9dba414d84472b1750e952a42710f6 diff --git a/tycho/CMakeLists.txt b/tycho/CMakeLists.txt index 6801c0c..1eada9a 100644 --- a/tycho/CMakeLists.txt +++ b/tycho/CMakeLists.txt @@ -41,7 +41,6 @@ add_library( ui/about.ui ui/license.ui ui/mapprops.ui - ui/mapview.ui ui/menu.ui ui/points.ui ui/project.ui diff --git a/tycho/bindings.json b/tycho/bindings.json index 53a8d37..778711c 100644 --- a/tycho/bindings.json +++ b/tycho/bindings.json @@ -56,7 +56,7 @@ } }, "IMapView": { - "type": "Object", + "type": "Widget", "baseClass": "IProjectView", "functions": { }, diff --git a/tycho/cc/interface.h b/tycho/cc/interface.h index f5bc388..1e7ad1e 100644 --- a/tycho/cc/interface.h +++ b/tycho/cc/interface.h @@ -32,16 +32,14 @@ signals: void selected(std::uint16_t index); }; -class IProjectView : public QObject +class IProjectView : public QWidget { Q_OBJECT public: - using QObject::QObject; + using QWidget::QWidget; virtual ~IProjectView() {} - - virtual QWidget *widget() = 0; }; // EOF diff --git a/tycho/cc/mapview.cc b/tycho/cc/mapview.cc index 9f29860..1e3ea06 100644 --- a/tycho/cc/mapview.cc +++ b/tycho/cc/mapview.cc @@ -2,10 +2,9 @@ MapView::MapView(Project *parent) : IMapView(parent), - m_internal(parent), m_mapModel(parent->mapModel()) { - setupUi(&m_internal); + setMinimumSize(320, 240); dbgPrintFunc(); } @@ -15,9 +14,17 @@ MapView::~MapView() dbgPrintFunc(); } -QWidget *MapView::widget() +void MapView::paintEvent(QPaintEvent *) { - return &m_internal; + [[maybe_unused]] QPainter painter{this}; +} + +// TODO: move to paint.cc +extern "C" { + void paint_point(QPainter *view, int x, int y) + { + view->drawPoint(x, y); + } } // EOF diff --git a/tycho/cc/project.cc b/tycho/cc/project.cc index f68b4a7..91b2872 100644 --- a/tycho/cc/project.cc +++ b/tycho/cc/project.cc @@ -30,7 +30,7 @@ Project::Project(Type type) : setAttribute(Qt::WA_DeleteOnClose); listView->setModel(m_model); - verticalLayout->insertWidget(0, m_view->widget()); + verticalLayout->insertWidget(0, m_view); connect(listView, SIGNAL(doubleClicked(QModelIndex const &)), diff --git a/tycho/cc/tycho.h b/tycho/cc/tycho.h index aa8a124..b91dbd3 100644 --- a/tycho/cc/tycho.h +++ b/tycho/cc/tycho.h @@ -15,11 +15,11 @@ #include #include #include +#include #include "../ui/ui_about.h" #include "../ui/ui_license.h" #include "../ui/ui_mapprops.h" -#include "../ui/ui_mapview.h" #include "../ui/ui_menu.h" #include "../ui/ui_project.h" @@ -47,8 +47,7 @@ private: QVariant data(const QModelIndex &index, int role) const override; }; -class MapView final : public IMapView, - private Ui::MapView +class MapView final : public IMapView { Q_OBJECT @@ -56,10 +55,10 @@ public: explicit MapView(Project *parent); ~MapView(); - QWidget *widget(); +protected: + void paintEvent(QPaintEvent *event) override; private: - QWidget m_internal; MapModel *const m_mapModel; }; diff --git a/tycho/ui/mapview.ui b/tycho/ui/mapview.ui deleted file mode 100644 index 8108af0..0000000 --- a/tycho/ui/mapview.ui +++ /dev/null @@ -1,24 +0,0 @@ - - - MapView - - - - 0 - 0 - 400 - 300 - - - - Map View - - - - - - - - - -