Compare commits

...

3 Commits

Author SHA1 Message Date
an 262ab3712e tycho: fix MapView sucking (and also remove RTTI) 2019-07-03 23:34:57 -04:00
an f9722647af tycho: quit using unnecessary casts 2019-07-03 23:22:15 -04:00
an 91182c6015 update LICENSE 2019-07-03 23:22:03 -04:00
8 changed files with 34 additions and 9 deletions

View File

@ -1,3 +1,8 @@
Modified source code from rust-qt-binding-generator is included as a submodule
under the directory of the same name. That code is GNU GPL with exception to the
generated code. It is only required to *build* Tycho, so this exception also
applies to any binary version of Tycho.
Some of the data contained in tests/data and benches/data is Copyright © Bungie Some of the data contained in tests/data and benches/data is Copyright © Bungie
Software. I do not own them, but am permitted to redistribute them. Everything Software. I do not own them, but am permitted to redistribute them. Everything
else is public domain, as stated: else is public domain, as stated:

View File

@ -9,7 +9,11 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror")
if(NOT MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif()
find_package( find_package(
Qt5 5.6.0 Qt5 5.6.0

View File

@ -57,6 +57,7 @@
}, },
"IMapView": { "IMapView": {
"type": "Object", "type": "Object",
"baseClass": "IProjectView",
"functions": { "functions": {
}, },
"properties": { "properties": {

View File

@ -3,6 +3,7 @@
#pragma clang diagnostic ignored "-Winconsistent-missing-override" #pragma clang diagnostic ignored "-Winconsistent-missing-override"
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QWidget>
class IProjectModel : public QAbstractItemModel class IProjectModel : public QAbstractItemModel
{ {
@ -31,10 +32,16 @@ signals:
void selected(std::uint16_t index); void selected(std::uint16_t index);
}; };
class IProjectView class IProjectView : public QObject
{ {
Q_OBJECT
public: public:
using QObject::QObject;
virtual ~IProjectView() {} virtual ~IProjectView() {}
virtual QWidget *widget() = 0;
}; };
// EOF // EOF

View File

@ -1,7 +1,7 @@
#include "tycho.h" #include "tycho.h"
MapProps::MapProps(Project *parent) : MapProps::MapProps(Project *parent) :
QDialog(static_cast<QWidget *>(parent)), QDialog(parent),
m_mapModel(parent->mapModel()) m_mapModel(parent->mapModel())
{ {
setupUi(this); setupUi(this);

View File

@ -1,10 +1,11 @@
#include "tycho.h" #include "tycho.h"
MapView::MapView(Project *parent) : MapView::MapView(Project *parent) :
QWidget(static_cast<QWidget *>(parent)), IMapView(parent),
m_internal(parent),
m_mapModel(parent->mapModel()) m_mapModel(parent->mapModel())
{ {
setupUi(this); setupUi(&m_internal);
dbgPrintFunc(); dbgPrintFunc();
} }
@ -14,4 +15,9 @@ MapView::~MapView()
dbgPrintFunc(); dbgPrintFunc();
} }
QWidget *MapView::widget()
{
return &m_internal;
}
// EOF // EOF

View File

@ -30,7 +30,7 @@ Project::Project(Type type) :
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
listView->setModel(m_model); listView->setModel(m_model);
verticalLayout->insertWidget(0, dynamic_cast<QWidget *>(m_view)); verticalLayout->insertWidget(0, m_view->widget());
connect(listView, connect(listView,
SIGNAL(doubleClicked(QModelIndex const &)), SIGNAL(doubleClicked(QModelIndex const &)),
@ -57,7 +57,7 @@ IProjectModel *Project::model() const
MapModel *Project::mapModel() const MapModel *Project::mapModel() const
{ {
return dynamic_cast<MapModel *>(m_model); return qobject_cast<MapModel *>(m_model);
} }
void Project::closeEvent(QCloseEvent *event) void Project::closeEvent(QCloseEvent *event)

View File

@ -47,8 +47,7 @@ private:
QVariant data(const QModelIndex &index, int role) const override; QVariant data(const QModelIndex &index, int role) const override;
}; };
class MapView final : public QWidget, class MapView final : public IMapView,
public IProjectView,
private Ui::MapView private Ui::MapView
{ {
Q_OBJECT Q_OBJECT
@ -57,7 +56,10 @@ public:
explicit MapView(Project *parent); explicit MapView(Project *parent);
~MapView(); ~MapView();
QWidget *widget();
private: private:
QWidget m_internal;
MapModel *const m_mapModel; MapModel *const m_mapModel;
}; };