1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-25 13:17:46 +00:00

Fix misc warnings, code errors and slight improvements

This commit is contained in:
Joshua Goins 2023-12-09 15:24:54 -05:00
parent 8bd7148b79
commit 88d80a64cf
35 changed files with 71 additions and 85 deletions

View file

@ -47,7 +47,7 @@ private:
QComboBox *raceCombo = nullptr, *subraceCombo = nullptr, *genderCombo = nullptr;
GameData *data = nullptr;
physis_CMP cmp;
physis_CMP cmp{};
float heightScale = 0.5f;
float bustScale = 1.0f;

View file

@ -6,7 +6,7 @@
#include "gearview.h"
BoneEditor::BoneEditor(GearView *gearView, QWidget *parent)
: SklbPart()
: SklbPart(parent)
, gearView(gearView)
{
connect(&gearView->part(), &MDLPart::skeletonChanged, this, [this, gearView] {

View file

@ -4,7 +4,7 @@
#include "cmpeditor.h"
CmpEditor::CmpEditor(GameData *data, QWidget *parent)
: CmpPart(data)
: CmpPart(data, parent)
{
setWindowTitle(QStringLiteral("CMP Editor"));

View file

@ -148,12 +148,12 @@ void FullModelViewer::addGear(GearInfo &info)
{
switch (info.slot) {
case Slot::Body:
if (topSlot ? *topSlot != info : true) {
if (!topSlot || *topSlot != info) {
topSlot = info;
}
break;
case Slot::Legs:
if (bottomSlot ? *bottomSlot != info : true) {
if (!bottomSlot || *bottomSlot != info) {
bottomSlot = info;
}
break;

View file

@ -3,7 +3,6 @@
#include "gearlistmodel.h"
#include <QDebug>
#include <QtConcurrent>
#include <magic_enum.hpp>
@ -76,7 +75,7 @@ int GearListModel::columnCount(const QModelIndex &parent) const
QModelIndex GearListModel::index(int row, int column, const QModelIndex &parent) const
{
if (!hasIndex(row, column, parent))
return QModelIndex();
return {};
TreeInformation *parentItem;
@ -88,19 +87,19 @@ QModelIndex GearListModel::index(int row, int column, const QModelIndex &parent)
TreeInformation *childItem = parentItem->children[row];
if (childItem)
return createIndex(row, column, childItem);
return QModelIndex();
return {};
}
QModelIndex GearListModel::parent(const QModelIndex &index) const
{
if (!index.isValid())
return QModelIndex();
return {};
TreeInformation *childItem = static_cast<TreeInformation *>(index.internalPointer());
auto childItem = static_cast<TreeInformation *>(index.internalPointer());
TreeInformation *parentItem = childItem->parent;
if (parentItem == rootItem)
return QModelIndex();
return {};
return createIndex(parentItem->row, 0, parentItem);
}
@ -109,13 +108,11 @@ QVariant GearListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return {};
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
return {};
TreeInformation *item = static_cast<TreeInformation *>(index.internalPointer());
auto item = static_cast<TreeInformation *>(index.internalPointer());
if (item->type == TreeType::Category) {
return QLatin1String(magic_enum::enum_name(*item->slotType).data());
@ -139,7 +136,7 @@ QVariant GearListModel::headerData(int section, Qt::Orientation orientation, int
std::optional<GearInfo> GearListModel::getGearFromIndex(const QModelIndex &index)
{
TreeInformation *item = static_cast<TreeInformation *>(index.internalPointer());
auto item = static_cast<TreeInformation *>(index.internalPointer());
if (item->type == TreeType::Item) {
return item->gear;
}
@ -173,7 +170,7 @@ void GearListModel::finished()
int i = 0;
for (auto slot : magic_enum::enum_values<Slot>()) {
TreeInformation *categoryItem = new TreeInformation();
auto categoryItem = new TreeInformation();
categoryItem->type = TreeType::Category;
categoryItem->slotType = slot;
categoryItem->parent = rootItem;
@ -181,9 +178,9 @@ void GearListModel::finished()
rootItem->children.push_back(categoryItem);
int j = 0;
for (auto gear : gears) {
for (const auto &gear : gears) {
if (gear.slot == slot) {
TreeInformation *item = new TreeInformation();
auto item = new TreeInformation();
item->type = TreeType::Item;
item->gear = gear;
item->parent = categoryItem;

View file

@ -3,7 +3,6 @@
#include "gearview.h"
#include <QDebug>
#include <QThreadPool>
#include <QVBoxLayout>
#include <QtConcurrent>
@ -353,7 +352,7 @@ void GearView::updatePart()
mdlPart->removeModel(queuedRemoval.mdl);
loadedGears.erase(std::remove_if(loadedGears.begin(),
loadedGears.end(),
[queuedRemoval](const LoadedGear other) {
[queuedRemoval](const LoadedGear &other) {
return queuedRemoval.info == other.info;
}),
loadedGears.end());

View file

@ -9,18 +9,13 @@
#include <QTableWidget>
#include <QTimer>
#include <KAboutApplicationDialog>
#include <KAboutData>
#include <QAction>
#include <QApplication>
#include <QDesktopServices>
#include <QFileDialog>
#include <QMenuBar>
#include <QPushButton>
#include <QTreeWidget>
#include <glm/gtc/type_ptr.hpp>
#include <magic_enum.hpp>
#include <physis.hpp>
#include "cmpeditor.h"
#include "filecache.h"

View file

@ -337,7 +337,7 @@ void SingleGearView::importModel(const QString &filename)
qInfo() << "Importing" << node.name;
const QStringList parts = QString::fromStdString(node.name).split(QLatin1Char(' '));
const QString name = parts[0];
const QString &name = parts[0];
const QStringList lodPartNumber = parts[2].split(QLatin1Char('.'));
const int lodNumber = lodPartNumber[0].toInt();

View file

@ -22,7 +22,7 @@ Q_SIGNALS:
private:
struct {
QDoubleSpinBox *x, *y, *z;
QDoubleSpinBox *x = nullptr, *y = nullptr, *z = nullptr;
} spinBoxes;
glm::quat &quat;

View file

@ -12,7 +12,7 @@ class MainWindow : public NovusMainWindow
Q_OBJECT
public:
MainWindow(GameData *data);
explicit MainWindow(GameData *data);
private:
GameData *data = nullptr;

View file

@ -14,7 +14,7 @@ class MainWindow : public NovusMainWindow
Q_OBJECT
public:
MainWindow(GameData *data);
explicit MainWindow(GameData *data);
protected:
void setupFileMenu(QMenu *menu) override;

View file

@ -25,8 +25,9 @@ const std::vector<RaceTree> raceTree = {{Race::Hyur, {Subrace::Midlander, Subrac
{Race::Hrothgar, {Subrace::Hellion, Subrace::Lost}},
{Race::Viera, {Subrace::Rava, Subrace::Veena}}};
CmpPart::CmpPart(GameData *data)
: data(data)
CmpPart::CmpPart(GameData *data, QWidget *parent)
: QWidget(parent)
, data(data)
{
layout = new QHBoxLayout();
setLayout(layout);
@ -41,7 +42,7 @@ void CmpPart::load(physis_Buffer file)
raceListWidget->setHeaderLabel(QStringLiteral("Race"));
layout->addWidget(raceListWidget);
for (auto race : raceTree) {
for (const auto &race : raceTree) {
auto item = new QTreeWidgetItem();
item->setText(0, QLatin1String(magic_enum::enum_name(race.baseRace).data()));
raceListWidget->addTopLevelItem(item);

View file

@ -28,7 +28,7 @@ class CmpPart : public QWidget
Q_OBJECT
public:
explicit CmpPart(GameData *data);
explicit CmpPart(GameData *data, QWidget *parent = nullptr);
void load(physis_Buffer file);
@ -36,7 +36,7 @@ private:
void loadRaceData(Race race, Subrace subrace);
GameData *data = nullptr;
physis_CMP cmp;
physis_CMP cmp{};
QDoubleSpinBox *maleMinSize = nullptr;
QDoubleSpinBox *maleMaxSize = nullptr;

View file

@ -34,7 +34,7 @@ EXDPart::EXDPart(GameData *data)
contentsBoxLayout->addWidget(pageTabWidget);
}
void EXDPart::loadSheet(QString name, physis_Buffer buffer)
void EXDPart::loadSheet(const QString &name, physis_Buffer buffer)
{
pageTabWidget->clear();
@ -64,7 +64,7 @@ void EXDPart::loadSheet(QString name, physis_Buffer buffer)
auto exh = physis_parse_excel_sheet_header(buffer);
QLayoutItem *child;
while ((child = headerFormLayout->takeAt(0)) != 0) {
while ((child = headerFormLayout->takeAt(0)) != nullptr) {
delete child->widget();
delete child;
}

View file

@ -17,7 +17,7 @@ class EXDPart : public QWidget
public:
explicit EXDPart(GameData *data);
void loadSheet(QString name, physis_Buffer buffer);
void loadSheet(const QString &name, physis_Buffer buffer);
private:
GameData *data = nullptr;
@ -27,7 +27,7 @@ private:
struct CachedExcel {
physis_EXH *exh = nullptr;
physis_EXD exd;
physis_EXD exd{};
};
QMap<QString, CachedExcel> cachedExcelSheets;
Language getSuitableLanguage(physis_EXH *pExh);

View file

@ -5,7 +5,6 @@
#include <QApplication>
#include <QBuffer>
#include <QClipboard>
#include <QFile>
QHexDocument::QHexDocument(QHexBuffer *buffer, QObject *parent)
: QObject(parent)

View file

@ -6,7 +6,6 @@
#include <QApplication>
#include <QFontDatabase>
#include <QHelpEvent>
#include <QPaintEvent>
#include <QPainter>
#include <QScrollBar>
#include <QToolTip>

View file

@ -11,7 +11,6 @@
#include <QVBoxLayout>
#include <QVulkanInstance>
#include <QVulkanWindow>
#include <QWindow>
#include <cmath>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/type_ptr.inl>
@ -505,7 +504,7 @@ void MDLPart::removeModel(const physis_MDL &mdl)
{
models.erase(std::remove_if(models.begin(),
models.end(),
[mdl](const RenderModel other) {
[mdl](const RenderModel &other) {
return mdl.lods == other.model.lods;
}),
models.end());

View file

@ -12,7 +12,6 @@
struct GameData;
class VulkanWindow;
class StandaloneWindow;
class FileCache;
class MDLPart : public QWidget
@ -77,12 +76,11 @@ private:
GameData *data = nullptr;
FileCache &cache;
physis_PBD pbd;
physis_PBD pbd{};
std::vector<RenderModel> models;
Renderer *renderer;
VulkanWindow *vkWindow;
StandaloneWindow *standaloneWindow;
Renderer *renderer = nullptr;
VulkanWindow *vkWindow = nullptr;
bool firstTimeSkeletonDataCalculated = false;
};

View file

@ -26,7 +26,7 @@ void SHPKPart::load(physis_Buffer buffer)
pageTabWidget->clear();
const auto addShader = [this](physis_Shader shader, QString name) {
const auto addShader = [this](physis_Shader shader, const QString &name) {
auto shaderTextEdit = new QTextEdit();
shaderTextEdit->setReadOnly(true);

View file

@ -7,7 +7,6 @@
#include <QGroupBox>
#include <QHBoxLayout>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/matrix_decompose.hpp>
#include "quaternionedit.h"
#include "vec3edit.h"
@ -29,7 +28,8 @@ void addItem(physis_Skeleton &skeleton, physis_Bone &bone, QTreeWidget *widget,
}
}
SklbPart::SklbPart()
SklbPart::SklbPart(QWidget *parent)
: QWidget(parent)
{
auto layout = new QHBoxLayout();
setLayout(layout);

View file

@ -19,7 +19,7 @@ class SklbPart : public QWidget
Q_OBJECT
public:
explicit SklbPart();
explicit SklbPart(QWidget *parent = nullptr);
void clear();
void load(physis_Skeleton file);

View file

@ -35,7 +35,7 @@ QPixmap ImageLabel::scaledPixmap() const
void ImageLabel::resizeEvent(QResizeEvent *e)
{
Q_UNUSED(e);
Q_UNUSED(e)
if (!pix.isNull()) {
QLabel::setPixmap(scaledPixmap());
}

View file

@ -12,7 +12,7 @@ struct RenderTarget;
class ImGuiPass
{
public:
ImGuiPass(Renderer &renderer);
explicit ImGuiPass(Renderer &renderer);
~ImGuiPass();
void render(VkCommandBuffer commandBuffer);

View file

@ -11,7 +11,7 @@ class FilePropertiesWindow : public QWidget
Q_OBJECT
public:
explicit FilePropertiesWindow(QString path, physis_Buffer buffer, QWidget *parent = nullptr);
explicit FilePropertiesWindow(const QString &path, physis_Buffer buffer, QWidget *parent = nullptr);
private:
GameData *data = nullptr;

View file

@ -26,7 +26,7 @@ class FileTreeModel : public QAbstractItemModel
Q_OBJECT
public:
explicit FileTreeModel(bool showUnknown, QString gamePath, GameData *data);
explicit FileTreeModel(bool showUnknown, const QString &gamePath, GameData *data);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
@ -41,8 +41,8 @@ private:
GameData *gameData = nullptr;
TreeInformation *rootItem = nullptr;
void addKnownFolder(QString string);
void addFile(TreeInformation *parentItem, uint32_t filenameHash, QString name);
void addKnownFolder(const QString &string);
void addFile(TreeInformation *parentItem, uint32_t filenameHash, const QString &name);
void addFolder(TreeInformation *parentItem, uint32_t filenameHash);
QHash<uint32_t, TreeInformation *> knownDirHashes;

View file

@ -14,18 +14,18 @@ class FileTreeWindow : public QWidget
Q_OBJECT
public:
explicit FileTreeWindow(QString gamePath, GameData *data, QWidget *parent = nullptr);
explicit FileTreeWindow(const QString &gamePath, GameData *data, QWidget *parent = nullptr);
Q_SIGNALS:
void extractFile(QString path);
void pathSelected(QString path);
void extractFile(const QString &path);
void pathSelected(const QString &path);
private:
void refreshModel();
GameData *data = nullptr;
FileTreeModel *m_fileModel;
QSortFilterProxyModel *m_searchModel;
QCheckBox *m_unknownCheckbox;
FileTreeModel *m_fileModel = nullptr;
QSortFilterProxyModel *m_searchModel = nullptr;
QCheckBox *m_unknownCheckbox = nullptr;
QString m_gamePath;
};

View file

@ -12,16 +12,16 @@ class HashDatabase : public QObject
Q_OBJECT
public:
HashDatabase(QObject *parent = nullptr);
explicit HashDatabase(QObject *parent = nullptr);
void addFolder(QString folder);
void addFile(QString file);
void addFolder(const QString &folder);
void addFile(const QString &file);
QVector<QString> getKnownFolders();
bool knowsFile(const uint32_t i);
bool knowsFile(uint32_t i);
QString getFilename(const uint32_t i);
QString getFilename(uint32_t i);
private:
QSqlDatabase m_db;

View file

@ -15,7 +15,7 @@ struct GameData;
class MainWindow : public NovusMainWindow
{
public:
MainWindow(QString gamePath, GameData *data);
MainWindow(const QString &gamePath, GameData *data);
private:
QMdiArea *mdiArea = nullptr;
@ -24,5 +24,5 @@ private:
QTabWidget *partHolder = nullptr;
FileCache fileCache;
void refreshParts(QString qString);
void refreshParts(const QString &path);
};

View file

@ -9,7 +9,7 @@
#include "filepropertieswindow.h"
FilePropertiesWindow::FilePropertiesWindow(QString path, physis_Buffer buffer, QWidget *parent)
FilePropertiesWindow::FilePropertiesWindow(const QString &path, physis_Buffer buffer, QWidget *parent)
: QWidget(parent)
{
setWindowTitle(QStringLiteral("Properties for ") + path);

View file

@ -6,7 +6,7 @@
#include <QtConcurrent>
FileTreeModel::FileTreeModel(bool showUnknown, QString gamePath, GameData *data)
FileTreeModel::FileTreeModel(bool showUnknown, const QString &gamePath, GameData *data)
: gameData(data)
, m_showUnknown(showUnknown)
, QAbstractItemModel()
@ -14,7 +14,7 @@ FileTreeModel::FileTreeModel(bool showUnknown, QString gamePath, GameData *data)
rootItem = new TreeInformation();
rootItem->type = TreeType::Root;
for (auto knownFolder : m_database.getKnownFolders()) {
for (const auto &knownFolder : m_database.getKnownFolders()) {
addKnownFolder(knownFolder);
}
@ -146,7 +146,7 @@ QVariant FileTreeModel::headerData(int section, Qt::Orientation orientation, int
return QAbstractItemModel::headerData(section, orientation, role);
}
void FileTreeModel::addKnownFolder(QString string)
void FileTreeModel::addKnownFolder(const QString &string)
{
auto children = string.split(QStringLiteral("/"));
@ -175,7 +175,7 @@ void FileTreeModel::addKnownFolder(QString string)
}
}
void FileTreeModel::addFile(TreeInformation *parentItem, uint32_t name, QString realName)
void FileTreeModel::addFile(TreeInformation *parentItem, uint32_t name, const QString &realName)
{
if (realName.isEmpty() && !m_showUnknown) {
return;

View file

@ -8,10 +8,10 @@
#include <QMenu>
#include <QTreeWidget>
FileTreeWindow::FileTreeWindow(QString gamePath, GameData *data, QWidget *parent)
FileTreeWindow::FileTreeWindow(const QString &gamePath, GameData *data, QWidget *parent)
: QWidget(parent)
, m_gamePath(gamePath)
, data(data)
, m_gamePath(gamePath)
{
auto layout = new QVBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);

View file

@ -21,7 +21,7 @@ HashDatabase::HashDatabase(QObject *parent)
query.exec(QStringLiteral("CREATE TABLE IF NOT EXISTS file_hashes (hash INTEGER PRIMARY KEY, name TEXT NOT NULL)"));
}
void HashDatabase::addFolder(QString folder)
void HashDatabase::addFolder(const QString &folder)
{
std::string folderStd = folder.toStdString();
@ -34,7 +34,7 @@ void HashDatabase::addFolder(QString folder)
query.exec();
}
void HashDatabase::addFile(QString file)
void HashDatabase::addFile(const QString &file)
{
QString filename = file;
if (file.contains(QStringLiteral("/"))) {

View file

@ -3,7 +3,6 @@
#include <QApplication>
#include <QStyle>
#include <physis.hpp>
#include "aboutdata.h"

View file

@ -21,7 +21,7 @@
#include "sklbpart.h"
#include "texpart.h"
MainWindow::MainWindow(QString gamePath, GameData *data)
MainWindow::MainWindow(const QString &gamePath, GameData *data)
: NovusMainWindow()
, data(data)
, fileCache(*data)
@ -35,7 +35,7 @@ MainWindow::MainWindow(QString gamePath, GameData *data)
dummyWidget->setLayout(layout);
auto tree = new FileTreeWindow(gamePath, data);
connect(tree, &FileTreeWindow::extractFile, this, [this, data](QString path) {
connect(tree, &FileTreeWindow::extractFile, this, [this, data](const QString &path) {
const QFileInfo info(path);
const QString savePath = QFileDialog::getSaveFileName(this, tr("Save File"), info.fileName(), QStringLiteral("*.%1").arg(info.completeSuffix()));
@ -50,7 +50,7 @@ MainWindow::MainWindow(QString gamePath, GameData *data)
file.write(reinterpret_cast<const char *>(fileData.data), fileData.size);
}
});
connect(tree, &FileTreeWindow::pathSelected, this, [=](QString path) {
connect(tree, &FileTreeWindow::pathSelected, this, [=](const QString &path) {
refreshParts(path);
});
tree->setMaximumWidth(200);
@ -64,7 +64,7 @@ MainWindow::MainWindow(QString gamePath, GameData *data)
refreshParts({});
}
void MainWindow::refreshParts(QString path)
void MainWindow::refreshParts(const QString &path)
{
partHolder->clear();