[nostalgia] Address CLion warnings
This commit is contained in:
parent
70168286ab
commit
936c922c1e
@ -183,11 +183,10 @@ constexpr bool Point::operator!=(const Point &p) const {
|
||||
|
||||
template<typename T>
|
||||
ox::Error model(T *io, Point *obj) {
|
||||
auto err = OxError(0);
|
||||
io->setTypeInfo("nostalgia::common::Bounds", 2);
|
||||
err |= io->field("x", &obj->x);
|
||||
err |= io->field("y", &obj->y);
|
||||
return err;
|
||||
oxReturnError(io->field("x", &obj->x));
|
||||
oxReturnError(io->field("y", &obj->y));
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <ox/std/std.hpp>
|
||||
|
||||
|
@ -139,7 +139,7 @@ void setTile(Context *ctx, int layer, int column, int row, uint8_t tile);
|
||||
|
||||
void clearTileLayer(Context*, int layer);
|
||||
|
||||
[[maybe_unused]] void hideSprite(Context*, unsigned);
|
||||
void hideSprite(Context*, unsigned);
|
||||
|
||||
void setSprite(Context*, unsigned idx, unsigned x, unsigned y, unsigned tileIdx, unsigned spriteShape = 0, unsigned spriteSize = 0, unsigned flipX = 0);
|
||||
|
||||
|
@ -29,6 +29,6 @@ namespace nostalgia::core {
|
||||
return colStart + colOffset + rowStart + rowOffset;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::unique_ptr<core::NostalgiaGraphic> imgToNg(QString argInPath, int argBpp = -1);
|
||||
[[nodiscard]] std::unique_ptr<core::NostalgiaGraphic> imgToNg(QString argInPath, int argBpp = -1);
|
||||
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 - 2021 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "json_read.hpp"
|
||||
#include "json_write.hpp"
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
class JsonOperator {
|
||||
|
||||
public:
|
||||
virtual ~JsonOperator() = default;
|
||||
|
||||
virtual int op(QString fieldName, int *dest) = 0;
|
||||
|
||||
virtual int op(QString fieldName, bool *dest) = 0;
|
||||
|
||||
virtual int op(QString fieldName, double *dest) = 0;
|
||||
|
||||
virtual int op(QString fieldName, QString *dest) = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -25,7 +25,7 @@ class JsonReader {
|
||||
QJsonObject &m_src;
|
||||
|
||||
public:
|
||||
JsonReader(QJsonObject &obj);
|
||||
explicit JsonReader(QJsonObject &obj);
|
||||
|
||||
ox::Error setTypeInfo(const char*, int) { return OxError(0); };
|
||||
|
||||
@ -44,16 +44,16 @@ class JsonReader {
|
||||
ox::Error field(QString fieldName, QVector<T> *dest);
|
||||
|
||||
private:
|
||||
ox::Error field(QJsonValueRef src, int *dest);
|
||||
static ox::Error field(QJsonValueRef src, int *dest);
|
||||
|
||||
ox::Error field(QJsonValueRef src, bool *dest);
|
||||
static ox::Error field(QJsonValueRef src, bool *dest);
|
||||
|
||||
ox::Error field(QJsonValueRef src, double *dest);
|
||||
static ox::Error field(QJsonValueRef src, double *dest);
|
||||
|
||||
ox::Error field(QJsonValueRef src, QString *dest);
|
||||
static ox::Error field(QJsonValueRef src, QString *dest);
|
||||
|
||||
template<typename T>
|
||||
ox::Error field(QJsonValueRef src, T *dest);
|
||||
static ox::Error field(QJsonValueRef src, T *dest);
|
||||
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,8 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <ox/std/assert.hpp>
|
||||
#include "json.hpp"
|
||||
#include "json_read.hpp"
|
||||
#include "json_write.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ox;
|
||||
|
@ -24,7 +24,7 @@ class JsonWriter {
|
||||
QJsonObject &m_dest;
|
||||
|
||||
public:
|
||||
JsonWriter(QJsonObject &obj);
|
||||
explicit JsonWriter(QJsonObject &obj);
|
||||
|
||||
ox::Error setTypeInfo(const char*, int) { return OxError(0); };
|
||||
|
||||
|
@ -35,7 +35,7 @@ void Editor::setUnsavedChanges(bool uc) {
|
||||
emit unsavedChangesChanged(uc);
|
||||
}
|
||||
|
||||
bool Editor::unsavedChanges() noexcept {
|
||||
bool Editor::unsavedChanges() const noexcept {
|
||||
return m_unsavedChanges;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class NOSTALGIASTUDIO_EXPORT Editor: public QWidget {
|
||||
*/
|
||||
void setUnsavedChanges(bool);
|
||||
|
||||
[[nodiscard]] bool unsavedChanges() noexcept;
|
||||
[[nodiscard]] bool unsavedChanges() const noexcept;
|
||||
|
||||
/**
|
||||
* Returns the undo stack holding changes to the item being edited.
|
||||
|
@ -19,10 +19,6 @@ QVector<WizardMaker> Module::importWizards(const Context*) {
|
||||
return {};
|
||||
}
|
||||
|
||||
QWidget *Module::makeEditor(QString, const Context*) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QVector<EditorMaker> Module::editors(const Context*) {
|
||||
return {};
|
||||
}
|
||||
|
@ -31,9 +31,7 @@ class Module {
|
||||
|
||||
virtual QVector<WizardMaker> importWizards(const Context *ctx);
|
||||
|
||||
virtual QWidget *makeEditor(QString path, const class Context *ctx);
|
||||
|
||||
virtual QVector<EditorMaker> editors(const class Context *ctx);
|
||||
virtual QVector<EditorMaker> editors(const class Context *ctx);
|
||||
|
||||
};
|
||||
|
||||
|
@ -25,8 +25,7 @@ Project::Project(QString path): m_fs(path.toUtf8()) {
|
||||
m_path = path;
|
||||
}
|
||||
|
||||
Project::~Project() {
|
||||
}
|
||||
Project::~Project() = default;
|
||||
|
||||
void Project::create() {
|
||||
QDir().mkpath(m_path);
|
||||
|
@ -43,9 +43,9 @@ class NOSTALGIASTUDIO_EXPORT Project: public QObject {
|
||||
mutable ox::PassThroughFS m_fs;
|
||||
|
||||
public:
|
||||
Project(QString path);
|
||||
explicit Project(QString path);
|
||||
|
||||
~Project();
|
||||
~Project() override;
|
||||
|
||||
void create();
|
||||
|
||||
|
@ -58,7 +58,7 @@ void WizardSelect::initializePage() {
|
||||
emit completeChanged();
|
||||
}
|
||||
|
||||
void WizardSelect::addOption(WizardMaker wm) {
|
||||
void WizardSelect::addOption(const WizardMaker &wm) {
|
||||
m_options[wm.name] = {wm.make, wm.onAccept};
|
||||
m_listWidget->addItem(wm.name);
|
||||
}
|
||||
@ -82,7 +82,6 @@ void WizardSelect::itemSelected(int row) {
|
||||
w->addPage(p);
|
||||
}
|
||||
w->setAccept(o.onAccept);
|
||||
|
||||
// for some reason the continue button only appears correctly after remove runs
|
||||
w->removePage(w->addPage(new QWizardPage()));
|
||||
}
|
||||
@ -96,9 +95,6 @@ WizardConclusionPage::WizardConclusionPage(QString msg, QVector<QString> fields)
|
||||
setLayout(new QVBoxLayout(this));
|
||||
}
|
||||
|
||||
WizardConclusionPage::~WizardConclusionPage() {
|
||||
}
|
||||
|
||||
void WizardConclusionPage::initializePage() {
|
||||
QString msg = m_baseMsg;
|
||||
for (auto field : m_fields) {
|
||||
@ -126,7 +122,7 @@ void WizardFormPage::Field::setDisplayText(QString text) {
|
||||
}
|
||||
}
|
||||
|
||||
QString WizardFormPage::Field::getDisplayText() {
|
||||
QString WizardFormPage::Field::getDisplayText() const {
|
||||
auto le = dynamic_cast<QLineEdit*>(this->valueControl);
|
||||
auto cb = dynamic_cast<QComboBox*>(this->valueControl);
|
||||
if (le) {
|
||||
|
@ -61,7 +61,7 @@ class NOSTALGIASTUDIO_EXPORT WizardSelect: public QWizardPage {
|
||||
public:
|
||||
WizardSelect();
|
||||
|
||||
void addOption(WizardMaker wm);
|
||||
void addOption(const WizardMaker &wm);
|
||||
|
||||
void initializePage() override;
|
||||
|
||||
@ -84,7 +84,7 @@ class NOSTALGIASTUDIO_EXPORT WizardFormPage: public QWizardPage {
|
||||
|
||||
void setDisplayText(QString text);
|
||||
|
||||
QString getDisplayText();
|
||||
QString getDisplayText() const;
|
||||
};
|
||||
QLabel *m_errorMsg = nullptr;
|
||||
QGridLayout *m_layout = nullptr;
|
||||
@ -129,7 +129,7 @@ class NOSTALGIASTUDIO_EXPORT WizardConclusionPage: public QWizardPage {
|
||||
public:
|
||||
WizardConclusionPage(QString msg, QVector<QString> field);
|
||||
|
||||
virtual ~WizardConclusionPage();
|
||||
~WizardConclusionPage() override = default;
|
||||
|
||||
void initializePage() override;
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ int main(int argc, char **args) {
|
||||
w.show();
|
||||
QObject::connect(&app, &QApplication::aboutToQuit, &w, &MainWindow::onExit);
|
||||
return app.exec();
|
||||
} catch (ox::Error err) {
|
||||
} catch (const ox::Error &err) {
|
||||
oxPanic(err, "Unhandled ox::Error");
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,8 @@
|
||||
#include "lib/project.hpp"
|
||||
#include "lib/wizard.hpp"
|
||||
|
||||
#include "json.hpp"
|
||||
#include "json_read.hpp"
|
||||
#include "json_write.hpp"
|
||||
#include "mainwindow.hpp"
|
||||
|
||||
namespace nostalgia::studio {
|
||||
@ -46,9 +47,9 @@ MainWindow::MainWindow(QString profilePath) {
|
||||
|
||||
// set window to 75% of screen width, and center NostalgiaStudioProfile
|
||||
constexpr auto sizePct = 0.75;
|
||||
resize(screenSize.width() * sizePct, screenSize.height() * sizePct);
|
||||
resize(static_cast<int>(screenSize.width() * sizePct), static_cast<int>(screenSize.height() * sizePct));
|
||||
move(-x(), -y());
|
||||
move(screenSize.width() * (1 - sizePct) / 2, screenSize.height() * (1 - sizePct) / 2);
|
||||
move(static_cast<int>(screenSize.width() * (1 - sizePct) / 2), static_cast<int>(screenSize.height() * (1 - sizePct) / 2));
|
||||
|
||||
setWindowTitle(m_profile.appName);
|
||||
m_ctx.appName = m_profile.appName;
|
||||
@ -312,7 +313,7 @@ void MainWindow::writeState() {
|
||||
/**
|
||||
* Read open editor tabs for current project.
|
||||
*/
|
||||
QStringList MainWindow::readTabs() {
|
||||
QStringList MainWindow::readTabs() const {
|
||||
QStringList tabs;
|
||||
QSettings settings(m_profile.orgName, m_profile.appName);
|
||||
settings.beginReadArray("MainWindow/Project:" + m_state.projectPath);
|
||||
@ -328,7 +329,7 @@ QStringList MainWindow::readTabs() {
|
||||
/**
|
||||
* Write open editor tabs for current project.
|
||||
*/
|
||||
void MainWindow::writeTabs(QStringList tabs) {
|
||||
void MainWindow::writeTabs(QStringList tabs) const {
|
||||
QSettings settings(m_profile.orgName, m_profile.appName);
|
||||
settings.beginWriteArray("MainWindow/Project:" + m_state.projectPath + "/openEditors");
|
||||
for (int i = 0; i < tabs.size(); i++) {
|
||||
@ -358,7 +359,7 @@ void MainWindow::openProject(QString projectPath) {
|
||||
for (auto t : openTabs) {
|
||||
try {
|
||||
openFile(t, true);
|
||||
} catch (ox::Error err) {
|
||||
} catch (const ox::Error &err) {
|
||||
qInfo().nospace() << "Error opening tab: " << t << ", " << static_cast<int>(err) << ", " << err.file << ":" << err.line;
|
||||
oxTrace("nostalgia::studio::MainWindow::openProject") << "Error opening tab:" << static_cast<int>(err)
|
||||
<< ", " << static_cast<int>(err) << ", " << err.file << ":" << err.line;
|
||||
@ -373,7 +374,7 @@ void MainWindow::openProject(QString projectPath) {
|
||||
void MainWindow::closeProject() {
|
||||
// delete tabs
|
||||
while (m_tabs->count()) {
|
||||
auto tab = static_cast<studio::Editor*>(m_tabs->widget(0));
|
||||
auto tab = dynamic_cast<studio::Editor*>(m_tabs->widget(0));
|
||||
m_undoGroup.removeStack(tab->undoStack());
|
||||
m_tabs->removeTab(0);
|
||||
delete tab;
|
||||
@ -529,7 +530,7 @@ void MainWindow::pasteAction() {
|
||||
}
|
||||
|
||||
void MainWindow::closeTab(int idx) {
|
||||
auto tab = static_cast<studio::Editor*>(m_tabs->widget(idx));
|
||||
auto tab = dynamic_cast<studio::Editor*>(m_tabs->widget(idx));
|
||||
m_undoGroup.removeStack(tab->undoStack());
|
||||
m_tabs->removeTab(idx);
|
||||
delete tab;
|
||||
@ -588,8 +589,6 @@ void MainWindow::markUnsavedChanges(bool unsavedChanges) {
|
||||
}
|
||||
|
||||
void MainWindow::showImportWizard() {
|
||||
const QString TILESHEET_NAME = "projectName";
|
||||
const QString IMPORT_PATH = "projectPath";
|
||||
const QString BPP = "bpp";
|
||||
Wizard wizard(tr("Import..."));
|
||||
auto ws = new WizardSelect();
|
||||
|
@ -85,9 +85,9 @@ class MainWindow: public QMainWindow {
|
||||
Editor *m_currentEditor = nullptr;
|
||||
|
||||
public:
|
||||
MainWindow(QString profilePath);
|
||||
explicit MainWindow(QString profilePath);
|
||||
|
||||
virtual ~MainWindow();
|
||||
~MainWindow() override;
|
||||
|
||||
private:
|
||||
void loadModules();
|
||||
@ -104,12 +104,12 @@ class MainWindow: public QMainWindow {
|
||||
|
||||
void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget);
|
||||
|
||||
QAction *addAction(QMenu *menu, QString text, QString toolTip, const QObject *tgt, const char *cb);
|
||||
static QAction *addAction(QMenu *menu, QString text, QString toolTip, const QObject *tgt, const char *cb);
|
||||
|
||||
QAction *addAction(QMenu *menu, QString text, QString toolTip,
|
||||
static QAction *addAction(QMenu *menu, QString text, QString toolTip,
|
||||
QKeySequence::StandardKey key, const QObject *tgt, const char *cb);
|
||||
|
||||
QAction *addAction(QMenu *menu, QString text, QString toolTip,
|
||||
static QAction *addAction(QMenu *menu, QString text, QString toolTip,
|
||||
QKeySequence::StandardKey key, void (*cb)());
|
||||
|
||||
int readState();
|
||||
@ -119,12 +119,12 @@ class MainWindow: public QMainWindow {
|
||||
/**
|
||||
* Read open editor tabs for current project.
|
||||
*/
|
||||
QStringList readTabs();
|
||||
[[nodiscard]] QStringList readTabs() const;
|
||||
|
||||
/**
|
||||
* Write open editor tabs for current project.
|
||||
*/
|
||||
void writeTabs(QStringList tabs);
|
||||
void writeTabs(QStringList tabs) const;
|
||||
|
||||
void openProject(QString);
|
||||
|
||||
|
@ -58,8 +58,8 @@ OxFSFile::~OxFSFile() {
|
||||
}
|
||||
|
||||
void OxFSFile::appendChild(OxFSModel *model, QStringList pathItems, QString currentPath) {
|
||||
if (pathItems.size()) {
|
||||
auto target = pathItems[0];
|
||||
if (!pathItems.empty()) {
|
||||
const auto &target = pathItems[0];
|
||||
currentPath += "/" + target;
|
||||
int index = m_childItems.size();
|
||||
for (int i = 0; i < m_childItems.size(); i++) {
|
||||
@ -138,7 +138,7 @@ QVariant OxFSModel::data(const QModelIndex &index, int role) const {
|
||||
if (!index.isValid() || role != Qt::DisplayRole) {
|
||||
return QVariant();
|
||||
} else {
|
||||
OxFSFile *item = static_cast<OxFSFile*>(index.internalPointer());
|
||||
auto item = static_cast<OxFSFile*>(index.internalPointer());
|
||||
return item->data(index.column());
|
||||
}
|
||||
}
|
||||
@ -184,8 +184,8 @@ QModelIndex OxFSModel::parent(const QModelIndex &index) const {
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
OxFSFile *childItem = static_cast<OxFSFile*>(index.internalPointer());
|
||||
OxFSFile *parentItem = childItem->parentItem();
|
||||
auto childItem = static_cast<OxFSFile*>(index.internalPointer());
|
||||
auto parentItem = childItem->parentItem();
|
||||
if (parentItem == m_rootItem) {
|
||||
return QModelIndex();
|
||||
}
|
||||
@ -221,7 +221,4 @@ void OxFSModel::updateFile(QString path) {
|
||||
m_rootItem->appendChild(this, pathItems, "");
|
||||
}
|
||||
|
||||
void OxFSModel::setupModelData(const QStringList&, OxFSFile*) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,19 +31,19 @@ class OxFSFile {
|
||||
|
||||
OxFSFile *child(int row);
|
||||
|
||||
int childCount() const;
|
||||
[[nodiscard]] int childCount() const;
|
||||
|
||||
int columnCount() const;
|
||||
[[nodiscard]] int columnCount() const;
|
||||
|
||||
QVariant data(int column) const;
|
||||
[[nodiscard]] QVariant data(int column) const;
|
||||
|
||||
int row() const;
|
||||
[[nodiscard]] int row() const;
|
||||
|
||||
OxFSFile *parentItem();
|
||||
|
||||
QString name() const;
|
||||
[[nodiscard]] QString name() const;
|
||||
|
||||
QString path() const;
|
||||
[[nodiscard]] QString path() const;
|
||||
};
|
||||
|
||||
class OxFSModel: public QAbstractItemModel {
|
||||
@ -55,31 +55,28 @@ class OxFSModel: public QAbstractItemModel {
|
||||
OxFSFile *m_rootItem = nullptr;
|
||||
|
||||
public:
|
||||
explicit OxFSModel(ox::PassThroughFS *fs, QObject *parent = 0);
|
||||
explicit OxFSModel(ox::PassThroughFS *fs, QObject *parent = nullptr);
|
||||
|
||||
~OxFSModel();
|
||||
~OxFSModel() override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
[[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
[[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const override;
|
||||
[[nodiscard]] QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent) const override;
|
||||
|
||||
QModelIndex parent(const QModelIndex &index) const override;
|
||||
[[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
[[nodiscard]] int rowCount(const QModelIndex &parent) const override;
|
||||
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
[[nodiscard]] int columnCount(const QModelIndex &parent) const override;
|
||||
|
||||
public slots:
|
||||
void updateFile(QString path);
|
||||
|
||||
private:
|
||||
void setupModelData(const QStringList &lines, OxFSFile *parent);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <vector>
|
||||
#include <ox/clargs/clargs.hpp>
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/std/units.hpp>
|
||||
|
||||
#include "pack/pack.hpp"
|
||||
|
||||
|
@ -39,12 +39,4 @@ QVector<WizardMaker> WorldEditorPlugin::newWizards(const Context *ctx) {
|
||||
};
|
||||
}
|
||||
|
||||
QWidget *WorldEditorPlugin::makeEditor(QString path, const Context *ctx) {
|
||||
if (path.startsWith(PATH_ZONES)) {
|
||||
return new WorldEditor(path, ctx);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,8 +22,6 @@ class WorldEditorPlugin: public QObject, public studio::Module {
|
||||
public:
|
||||
QVector<studio::WizardMaker> newWizards(const studio::Context *ctx) override;
|
||||
|
||||
QWidget *makeEditor(QString path, const studio::Context *ctx) override;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user