2019-07-02 14:57:10 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <iostream>
|
2019-07-03 16:23:04 -07:00
|
|
|
#include <optional>
|
2019-07-02 14:57:10 -07:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QCloseEvent>
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QMdiSubWindow>
|
|
|
|
#include <QMessageBox>
|
2019-07-10 02:15:12 -07:00
|
|
|
#include <QPainter>
|
2019-07-02 14:57:10 -07:00
|
|
|
|
|
|
|
#include "../ui/ui_about.h"
|
|
|
|
#include "../ui/ui_license.h"
|
|
|
|
#include "../ui/ui_mapprops.h"
|
|
|
|
#include "../ui/ui_menu.h"
|
|
|
|
#include "../ui/ui_project.h"
|
|
|
|
|
2019-07-03 20:17:04 -07:00
|
|
|
#include "bindings.h"
|
2019-07-03 16:33:50 -07:00
|
|
|
|
2019-07-03 20:17:04 -07:00
|
|
|
#pragma clang diagnostic warning "-Winconsistent-missing-override"
|
2019-07-02 14:57:10 -07:00
|
|
|
|
2019-07-03 20:17:04 -07:00
|
|
|
class Project;
|
2019-07-02 14:57:10 -07:00
|
|
|
|
2019-07-03 20:17:04 -07:00
|
|
|
using byte = std::uint8_t;
|
2019-07-03 16:23:04 -07:00
|
|
|
|
2019-07-03 20:17:04 -07:00
|
|
|
class MapModel final : public IMapModel
|
2019-07-02 14:57:10 -07:00
|
|
|
{
|
2019-07-05 20:21:11 -07:00
|
|
|
Q_OBJECT
|
2019-07-02 14:57:10 -07:00
|
|
|
|
|
|
|
public:
|
2019-07-05 20:21:11 -07:00
|
|
|
explicit MapModel(Project *parent);
|
|
|
|
~MapModel() override;
|
2019-07-02 14:57:10 -07:00
|
|
|
|
2019-07-03 16:26:28 -07:00
|
|
|
public slots:
|
2019-07-05 20:21:11 -07:00
|
|
|
void deselect() override;
|
|
|
|
void select(QModelIndex const &index) override;
|
2019-07-03 16:26:28 -07:00
|
|
|
|
2019-07-02 14:57:10 -07:00
|
|
|
private:
|
2019-07-05 20:21:11 -07:00
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
2019-07-02 14:57:10 -07:00
|
|
|
};
|
|
|
|
|
2019-07-10 02:15:12 -07:00
|
|
|
class MapView final : public IMapView
|
2019-07-02 17:22:25 -07:00
|
|
|
{
|
2019-07-05 20:21:11 -07:00
|
|
|
Q_OBJECT
|
2019-07-02 17:22:25 -07:00
|
|
|
|
|
|
|
public:
|
2019-07-05 20:21:11 -07:00
|
|
|
explicit MapView(Project *parent);
|
|
|
|
~MapView();
|
2019-07-02 17:22:25 -07:00
|
|
|
|
2019-07-10 02:15:12 -07:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
2019-07-03 20:34:57 -07:00
|
|
|
|
2019-07-02 17:22:25 -07:00
|
|
|
private:
|
2019-07-05 20:21:11 -07:00
|
|
|
MapModel *const m_mapModel;
|
2019-07-02 17:22:25 -07:00
|
|
|
};
|
|
|
|
|
2019-07-03 17:51:38 -07:00
|
|
|
class MapProps final : public QDialog,
|
|
|
|
private Ui::MapProps
|
2019-07-02 17:22:25 -07:00
|
|
|
{
|
2019-07-05 20:21:11 -07:00
|
|
|
Q_OBJECT
|
2019-07-02 17:22:25 -07:00
|
|
|
|
|
|
|
public:
|
2019-07-05 20:21:11 -07:00
|
|
|
explicit MapProps(Project *parent);
|
|
|
|
~MapProps();
|
2019-07-03 16:23:04 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
void accept() override;
|
2019-07-02 17:22:25 -07:00
|
|
|
|
|
|
|
private:
|
2019-07-05 20:21:11 -07:00
|
|
|
MapModel *const m_mapModel;
|
2019-07-02 17:22:25 -07:00
|
|
|
};
|
|
|
|
|
2019-07-03 17:51:38 -07:00
|
|
|
class Menu final : public QMainWindow,
|
|
|
|
private Ui::Menu
|
2019-07-02 14:57:10 -07:00
|
|
|
{
|
2019-07-05 20:21:11 -07:00
|
|
|
Q_OBJECT
|
2019-07-02 14:57:10 -07:00
|
|
|
|
|
|
|
public:
|
2019-07-05 20:21:11 -07:00
|
|
|
explicit Menu(QWidget *parent = nullptr);
|
|
|
|
~Menu();
|
2019-07-02 14:57:10 -07:00
|
|
|
|
|
|
|
public slots:
|
2019-07-05 20:21:11 -07:00
|
|
|
void mapNew();
|
|
|
|
void mapOpen();
|
|
|
|
void openAbout();
|
|
|
|
void openAboutQt();
|
|
|
|
void openMapProperties();
|
|
|
|
void updateActions();
|
2019-07-02 14:57:10 -07:00
|
|
|
|
|
|
|
protected:
|
2019-07-05 20:21:11 -07:00
|
|
|
void closeEvent(QCloseEvent *event) override;
|
|
|
|
void openLicense(QWidget *parent);
|
2019-07-02 14:57:10 -07:00
|
|
|
|
|
|
|
private:
|
2019-07-05 20:21:11 -07:00
|
|
|
Project *activeProject() const;
|
|
|
|
QMdiSubWindow *activeSubWindow() const;
|
2019-07-03 16:23:04 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
void addProject(Project *proj);
|
2019-07-02 14:57:10 -07:00
|
|
|
};
|
|
|
|
|
2019-07-03 17:51:38 -07:00
|
|
|
class Project final : public QMdiSubWindow,
|
|
|
|
private Ui::Project
|
2019-07-02 17:22:25 -07:00
|
|
|
{
|
2019-07-05 20:21:11 -07:00
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(Type type READ type CONSTANT)
|
|
|
|
Q_PROPERTY(IProjectModel *model READ model CONSTANT)
|
|
|
|
Q_PROPERTY(MapModel *mapModel READ mapModel CONSTANT)
|
2019-07-02 17:22:25 -07:00
|
|
|
|
|
|
|
public:
|
2019-07-05 20:21:11 -07:00
|
|
|
enum Type {Map};
|
|
|
|
Q_ENUM(Type)
|
2019-07-02 17:22:25 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
explicit Project(Type type);
|
|
|
|
~Project();
|
2019-07-03 16:23:04 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
Type type() const;
|
|
|
|
IProjectModel *model() const;
|
|
|
|
MapModel *mapModel() const;
|
2019-07-02 17:22:25 -07:00
|
|
|
|
|
|
|
protected:
|
2019-07-05 20:21:11 -07:00
|
|
|
void closeEvent(QCloseEvent *event) override;
|
2019-07-02 17:22:25 -07:00
|
|
|
|
|
|
|
private:
|
2019-07-05 20:21:11 -07:00
|
|
|
Type const m_type;
|
|
|
|
IProjectModel *const m_model;
|
|
|
|
IProjectView *const m_view;
|
2019-07-02 17:22:25 -07:00
|
|
|
};
|
|
|
|
|
2019-07-03 16:25:55 -07:00
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wformat-security"
|
|
|
|
|
2019-07-02 16:23:09 -07:00
|
|
|
template<typename... VA>
|
2019-07-03 16:27:47 -07:00
|
|
|
static inline
|
|
|
|
void dbgPrint([[maybe_unused]] char const *fmt, [[maybe_unused]] VA &&...va)
|
2019-07-02 16:23:09 -07:00
|
|
|
{
|
2019-07-05 20:21:11 -07:00
|
|
|
#ifdef TYCHO_DEBUG_ASSERTIONS
|
|
|
|
qDebug(fmt, std::forward<VA>(va)...);
|
|
|
|
#endif
|
2019-07-02 16:23:09 -07:00
|
|
|
}
|
|
|
|
|
2019-07-03 16:25:55 -07:00
|
|
|
#pragma clang diagnostic pop
|
|
|
|
|
2019-07-02 16:23:09 -07:00
|
|
|
#define dbgPrintFunc() dbgPrint("%s", __func__)
|
|
|
|
|
2019-07-03 16:27:47 -07:00
|
|
|
constexpr
|
2019-07-03 16:33:50 -07:00
|
|
|
std::uint32_t fourCC(byte a, byte b, byte c, byte d)
|
2019-07-02 14:57:10 -07:00
|
|
|
{
|
2019-07-05 20:21:11 -07:00
|
|
|
return (static_cast<std::uint32_t>(a) << 24) |
|
|
|
|
(static_cast<std::uint32_t>(b) << 16) |
|
|
|
|
(static_cast<std::uint32_t>(c) << 8) |
|
|
|
|
static_cast<std::uint32_t>(d);
|
2019-07-02 14:57:10 -07:00
|
|
|
}
|
|
|
|
|
2019-07-05 23:35:03 -07:00
|
|
|
QIcon getIcon(QString const &name);
|
|
|
|
|
2019-07-02 14:57:10 -07:00
|
|
|
extern "C" {
|
2019-07-05 20:21:11 -07:00
|
|
|
char const *tychoAuthors();
|
|
|
|
char const *tychoHomepage();
|
|
|
|
char const *tychoLicenseText();
|
|
|
|
char const *tychoRepository();
|
|
|
|
char const *tychoVersion();
|
2019-07-02 14:57:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// EOF
|