tycho: rename classes for consistency
parent
004989ab58
commit
fa7d785212
|
@ -6,16 +6,15 @@
|
||||||
"implementationModule": "gui"
|
"implementationModule": "gui"
|
||||||
},
|
},
|
||||||
"objects": {
|
"objects": {
|
||||||
"AbstractMapModel": {
|
"IMapModel": {
|
||||||
"type": "List",
|
"type": "List",
|
||||||
"functions": {
|
"functions": {
|
||||||
"open": {
|
"open": {
|
||||||
"return": "bool",
|
"return": "bool",
|
||||||
"mut": true,
|
"mut": true,
|
||||||
"arguments": [{
|
"arguments": [
|
||||||
"name": "path",
|
{"name": "path", "type": "QString"}
|
||||||
"type": "QString"
|
]
|
||||||
}]
|
|
||||||
},
|
},
|
||||||
"save": {
|
"save": {
|
||||||
"return": "bool",
|
"return": "bool",
|
||||||
|
@ -24,10 +23,9 @@
|
||||||
"saveAs": {
|
"saveAs": {
|
||||||
"return": "bool",
|
"return": "bool",
|
||||||
"mut": false,
|
"mut": false,
|
||||||
"arguments": [{
|
"arguments": [
|
||||||
"name": "path",
|
{"name": "path", "type": "QString"}
|
||||||
"type": "QString"
|
]
|
||||||
}]
|
|
||||||
},
|
},
|
||||||
"isDirty": {
|
"isDirty": {
|
||||||
"return": "bool",
|
"return": "bool",
|
||||||
|
@ -36,10 +34,9 @@
|
||||||
"propIcon": {
|
"propIcon": {
|
||||||
"return": "QString",
|
"return": "QString",
|
||||||
"mut": false,
|
"mut": false,
|
||||||
"arguments": [{
|
"arguments": [
|
||||||
"name": "index",
|
{"name": "index", "type": "quint16"}
|
||||||
"type": "quint16"
|
]
|
||||||
}]
|
|
||||||
},
|
},
|
||||||
"deselect": {
|
"deselect": {
|
||||||
"return": "void",
|
"return": "void",
|
||||||
|
@ -48,19 +45,15 @@
|
||||||
"select": {
|
"select": {
|
||||||
"return": "void",
|
"return": "void",
|
||||||
"mut": true,
|
"mut": true,
|
||||||
"arguments": [{
|
"arguments": [
|
||||||
"name": "index",
|
{"name": "index", "type": "quint16"}
|
||||||
"type": "quint16"
|
]
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
},
|
},
|
||||||
"itemProperties": {
|
"itemProperties": {
|
||||||
"propIndex": {
|
"propIndex": {"type": "quint64", "roles": [["display"]]}
|
||||||
"type": "quint64",
|
|
||||||
"roles": [["display"]]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,54 +1,54 @@
|
||||||
#include "tycho.h"
|
#include "tycho.h"
|
||||||
|
|
||||||
MapModel::MapModel(Project *parent) :
|
CMapModel::CMapModel(Project *parent) :
|
||||||
AbstractMapModel(static_cast<QWidget *>(parent)),
|
IMapModel(static_cast<QWidget *>(parent)),
|
||||||
ProjectModel()
|
IProjectModel()
|
||||||
{
|
{
|
||||||
dbgPrintFunc();
|
dbgPrintFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
MapModel::~MapModel()
|
CMapModel::~CMapModel()
|
||||||
{
|
{
|
||||||
dbgPrintFunc();
|
dbgPrintFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapModel::isDirty() const
|
bool CMapModel::isDirty() const
|
||||||
{
|
{
|
||||||
return AbstractMapModel::isDirty();
|
return IMapModel::isDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapModel::open(QString const &path)
|
bool CMapModel::open(QString const &path)
|
||||||
{
|
{
|
||||||
return AbstractMapModel::open(path);
|
return IMapModel::open(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapModel::save() const
|
bool CMapModel::save() const
|
||||||
{
|
{
|
||||||
return AbstractMapModel::save();
|
return IMapModel::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapModel::saveAs(QString const &path) const
|
bool CMapModel::saveAs(QString const &path) const
|
||||||
{
|
{
|
||||||
return AbstractMapModel::saveAs(path);
|
return IMapModel::saveAs(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapModel::deselect()
|
void CMapModel::deselect()
|
||||||
{
|
{
|
||||||
AbstractMapModel::deselect();
|
IMapModel::deselect();
|
||||||
|
|
||||||
emit deselected();
|
emit deselected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapModel::select(QModelIndex const &index)
|
void CMapModel::select(QModelIndex const &index)
|
||||||
{
|
{
|
||||||
auto idx = index.internalId();
|
auto idx = index.internalId();
|
||||||
|
|
||||||
AbstractMapModel::select(idx);
|
IMapModel::select(idx);
|
||||||
|
|
||||||
emit selected(idx);
|
emit selected(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant MapModel::data(const QModelIndex &index, int role) const
|
QVariant CMapModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
switch(role) {
|
switch(role) {
|
||||||
case Qt::DecorationRole: {
|
case Qt::DecorationRole: {
|
||||||
|
@ -58,7 +58,7 @@ QVariant MapModel::data(const QModelIndex &index, int role) const
|
||||||
return QVariant::fromValue(icon);
|
return QVariant::fromValue(icon);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return AbstractMapModel::data(index, role);
|
return IMapModel::data(index, role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "tycho.h"
|
#include "tycho.h"
|
||||||
|
|
||||||
MapView::MapView(Project *parent) :
|
CMapView::CMapView(Project *parent) :
|
||||||
QWidget(static_cast<QWidget *>(parent)),
|
QWidget(static_cast<QWidget *>(parent)),
|
||||||
mapModel(parent->getMapModel())
|
mapModel(parent->getMapModel())
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@ MapView::MapView(Project *parent) :
|
||||||
dbgPrintFunc();
|
dbgPrintFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
MapView::~MapView()
|
CMapView::~CMapView()
|
||||||
{
|
{
|
||||||
dbgPrintFunc();
|
dbgPrintFunc();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "tycho.h"
|
#include "tycho.h"
|
||||||
|
|
||||||
static
|
static
|
||||||
ProjectModel *makeModel(Project *proj)
|
IProjectModel *makeModel(Project *proj)
|
||||||
{
|
{
|
||||||
switch(proj->getType()) {
|
switch(proj->getType()) {
|
||||||
case ProjectType::Map: return new MapModel(proj);
|
case ProjectType::Map: return new MapModel(proj);
|
||||||
|
@ -9,7 +9,7 @@ ProjectModel *makeModel(Project *proj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
ProjectView *makeView(Project *proj)
|
IProjectView *makeView(Project *proj)
|
||||||
{
|
{
|
||||||
switch(proj->getType()) {
|
switch(proj->getType()) {
|
||||||
case ProjectType::Map: return new MapView(proj);
|
case ProjectType::Map: return new MapView(proj);
|
||||||
|
|
|
@ -25,14 +25,6 @@
|
||||||
#include "../ui/ui_menu.h"
|
#include "../ui/ui_menu.h"
|
||||||
#include "../ui/ui_project.h"
|
#include "../ui/ui_project.h"
|
||||||
|
|
||||||
// Types ---------------------------------------------------------------------|
|
|
||||||
|
|
||||||
class MapModel;
|
|
||||||
class MapProps;
|
|
||||||
class MapView;
|
|
||||||
class Menu;
|
|
||||||
class Project;
|
|
||||||
|
|
||||||
enum class ProjectType
|
enum class ProjectType
|
||||||
{
|
{
|
||||||
Map,
|
Map,
|
||||||
|
@ -40,12 +32,10 @@ enum class ProjectType
|
||||||
|
|
||||||
using byte = std::uint8_t;
|
using byte = std::uint8_t;
|
||||||
|
|
||||||
// Interfaces ----------------------------------------------------------------|
|
class IProjectModel
|
||||||
|
|
||||||
class ProjectModel
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ProjectModel() {}
|
virtual ~IProjectModel() {}
|
||||||
|
|
||||||
virtual bool isDirty() const = 0;
|
virtual bool isDirty() const = 0;
|
||||||
virtual bool open(QString const &path) = 0;
|
virtual bool open(QString const &path) = 0;
|
||||||
|
@ -53,21 +43,20 @@ public:
|
||||||
virtual bool saveAs(QString const &path) const = 0;
|
virtual bool saveAs(QString const &path) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProjectView
|
class IProjectView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ProjectView() {}
|
virtual ~IProjectView() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Implementations -----------------------------------------------------------|
|
class CMapModel final : public IMapModel,
|
||||||
|
public IProjectModel
|
||||||
class MapModel final : public AbstractMapModel, public ProjectModel
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MapModel(Project *parent);
|
explicit CMapModel(Project *parent);
|
||||||
~MapModel() override;
|
~CMapModel() override;
|
||||||
|
|
||||||
bool isDirty() const override;
|
bool isDirty() const override;
|
||||||
bool open(QString const &path) override;
|
bool open(QString const &path) override;
|
||||||
|
@ -87,21 +76,22 @@ private:
|
||||||
const override;
|
const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapView final : public QWidget, public ProjectView, private Ui::MapView
|
class CMapView final : public QWidget,
|
||||||
|
public IProjectView,
|
||||||
|
private Ui::CMapView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MapView(Project *parent);
|
explicit CMapView(Project *parent);
|
||||||
~MapView();
|
~CMapView();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MapModel *const mapModel;
|
CMapModel *const m_mapModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
// UI ------------------------------------------------------------------------|
|
class MapProps final : public QDialog,
|
||||||
|
private Ui::MapProps
|
||||||
class MapProps final : public QDialog, private Ui::MapProps
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -112,10 +102,11 @@ public:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MapModel *const mapModel;
|
CMapModel *const m_mapModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Menu final : public QMainWindow, private Ui::Menu
|
class Menu final : public QMainWindow,
|
||||||
|
private Ui::Menu
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -142,7 +133,8 @@ private:
|
||||||
void addProject(Project *proj);
|
void addProject(Project *proj);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Project final : public QMdiSubWindow, private Ui::Project
|
class Project final : public QMdiSubWindow,
|
||||||
|
private Ui::Project
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -165,8 +157,6 @@ private:
|
||||||
ProjectView *const view;
|
ProjectView *const view;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Functions -----------------------------------------------------------------|
|
|
||||||
|
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wformat-security"
|
#pragma clang diagnostic ignored "-Wformat-security"
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
//! GUI implementation.
|
//! GUI implementation.
|
||||||
|
|
||||||
mod map;
|
mod mapmodel;
|
||||||
mod qobj;
|
mod qobj;
|
||||||
|
|
||||||
pub use self::map::AbstractMapModel;
|
pub use self::mapmodel::IMapModel;
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
@ -4,7 +4,7 @@ use super::qobj::*;
|
||||||
use maraiah::{backtrace, err::*, map::{self, data::*}};
|
use maraiah::{backtrace, err::*, map::{self, data::*}};
|
||||||
use crate::cc;
|
use crate::cc;
|
||||||
|
|
||||||
impl AbstractMapModel
|
impl IMapModel
|
||||||
{
|
{
|
||||||
pub fn open_map(path: String) -> ResultS<EntryDataMap>
|
pub fn open_map(path: String) -> ResultS<EntryDataMap>
|
||||||
{
|
{
|
||||||
|
@ -29,20 +29,20 @@ impl AbstractMapModel
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AbstractMapModelTrait for AbstractMapModel
|
impl IMapModelTrait for IMapModel
|
||||||
{
|
{
|
||||||
/// Returns a new `AbstractMapModel` instance.
|
/// Returns a new `IMapModel` instance.
|
||||||
fn new(emit: AbstractMapModelEmitter, _: AbstractMapModelList) -> Self
|
fn new(emit: IMapModelEmitter, _: IMapModelList) -> Self
|
||||||
{
|
{
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
eprintln!("new AbstractMapModel");
|
eprintln!("new IMapModel");
|
||||||
}
|
}
|
||||||
|
|
||||||
Self{emit, map: EntryDataMap::default(), selected: None}
|
Self{emit, map: EntryDataMap::default(), selected: None}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the emitter of `self`.
|
/// Returns the emitter of `self`.
|
||||||
fn emit(&mut self) -> &mut AbstractMapModelEmitter {&mut self.emit}
|
fn emit(&mut self) -> &mut IMapModelEmitter {&mut self.emit}
|
||||||
|
|
||||||
fn row_count(&self) -> usize {self.map.len()}
|
fn row_count(&self) -> usize {self.map.len()}
|
||||||
|
|
||||||
|
@ -113,18 +113,18 @@ impl AbstractMapModelTrait for AbstractMapModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for AbstractMapModel
|
impl Drop for IMapModel
|
||||||
{
|
{
|
||||||
fn drop(&mut self)
|
fn drop(&mut self)
|
||||||
{
|
{
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
eprintln!("drop AbstractMapModel");
|
eprintln!("drop IMapModel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AbstractMapModel {
|
pub struct IMapModel {
|
||||||
emit: AbstractMapModelEmitter,
|
emit: IMapModelEmitter,
|
||||||
map: EntryDataMap,
|
map: EntryDataMap,
|
||||||
selected: Option<u16>,
|
selected: Option<u16>,
|
||||||
}
|
}
|
Loading…
Reference in New Issue