From 88d80a64cfc5cc32710567e33b054517f3dc7987 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 9 Dec 2023 15:24:54 -0500 Subject: [PATCH] Fix misc warnings, code errors and slight improvements --- armoury/include/fullmodelviewer.h | 2 +- armoury/src/boneeditor.cpp | 2 +- armoury/src/cmpeditor.cpp | 2 +- armoury/src/fullmodelviewer.cpp | 4 ++-- armoury/src/gearlistmodel.cpp | 25 +++++++++++-------------- armoury/src/gearview.cpp | 3 +-- armoury/src/mainwindow.cpp | 5 ----- armoury/src/singlegearview.cpp | 2 +- common/include/quaternionedit.h | 2 +- karuku/include/mainwindow.h | 2 +- mdlviewer/include/mainwindow.h | 2 +- parts/cmp/cmppart.cpp | 7 ++++--- parts/cmp/cmppart.h | 4 ++-- parts/exd/exdpart.cpp | 4 ++-- parts/exd/exdpart.h | 4 ++-- parts/hex/document/qhexdocument.cpp | 1 - parts/hex/qhexview.cpp | 1 - parts/mdl/mdlpart.cpp | 3 +-- parts/mdl/mdlpart.h | 8 +++----- parts/shpk/shpkpart.cpp | 2 +- parts/sklb/sklbpart.cpp | 4 ++-- parts/sklb/sklbpart.h | 2 +- parts/tex/imagelabel.cpp | 2 +- renderer/src/imguipass.h | 2 +- sagasu/include/filepropertieswindow.h | 2 +- sagasu/include/filetreemodel.h | 6 +++--- sagasu/include/filetreewindow.h | 12 ++++++------ sagasu/include/hashdatabase.h | 10 +++++----- sagasu/include/mainwindow.h | 4 ++-- sagasu/src/filepropertieswindow.cpp | 2 +- sagasu/src/filetreemodel.cpp | 8 ++++---- sagasu/src/filetreewindow.cpp | 4 ++-- sagasu/src/hashdatabase.cpp | 4 ++-- sagasu/src/main.cpp | 1 - sagasu/src/mainwindow.cpp | 8 ++++---- 35 files changed, 71 insertions(+), 85 deletions(-) diff --git a/armoury/include/fullmodelviewer.h b/armoury/include/fullmodelviewer.h index 8419235..2c10eb8 100644 --- a/armoury/include/fullmodelviewer.h +++ b/armoury/include/fullmodelviewer.h @@ -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; diff --git a/armoury/src/boneeditor.cpp b/armoury/src/boneeditor.cpp index 2419bd1..77ed834 100644 --- a/armoury/src/boneeditor.cpp +++ b/armoury/src/boneeditor.cpp @@ -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] { diff --git a/armoury/src/cmpeditor.cpp b/armoury/src/cmpeditor.cpp index 6cc7dda..956521e 100644 --- a/armoury/src/cmpeditor.cpp +++ b/armoury/src/cmpeditor.cpp @@ -4,7 +4,7 @@ #include "cmpeditor.h" CmpEditor::CmpEditor(GameData *data, QWidget *parent) - : CmpPart(data) + : CmpPart(data, parent) { setWindowTitle(QStringLiteral("CMP Editor")); diff --git a/armoury/src/fullmodelviewer.cpp b/armoury/src/fullmodelviewer.cpp index 4c8ef61..1f28fba 100644 --- a/armoury/src/fullmodelviewer.cpp +++ b/armoury/src/fullmodelviewer.cpp @@ -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; diff --git a/armoury/src/gearlistmodel.cpp b/armoury/src/gearlistmodel.cpp index 62758b5..ecb8889 100644 --- a/armoury/src/gearlistmodel.cpp +++ b/armoury/src/gearlistmodel.cpp @@ -3,7 +3,6 @@ #include "gearlistmodel.h" -#include #include #include @@ -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(index.internalPointer()); + auto childItem = static_cast(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(index.internalPointer()); + auto item = static_cast(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 GearListModel::getGearFromIndex(const QModelIndex &index) { - TreeInformation *item = static_cast(index.internalPointer()); + auto item = static_cast(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()) { - 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; diff --git a/armoury/src/gearview.cpp b/armoury/src/gearview.cpp index 8dca1ad..2e51431 100644 --- a/armoury/src/gearview.cpp +++ b/armoury/src/gearview.cpp @@ -3,7 +3,6 @@ #include "gearview.h" -#include #include #include #include @@ -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()); diff --git a/armoury/src/mainwindow.cpp b/armoury/src/mainwindow.cpp index a509ef9..78bffef 100644 --- a/armoury/src/mainwindow.cpp +++ b/armoury/src/mainwindow.cpp @@ -9,18 +9,13 @@ #include #include -#include #include #include #include #include #include #include -#include -#include -#include #include -#include #include "cmpeditor.h" #include "filecache.h" diff --git a/armoury/src/singlegearview.cpp b/armoury/src/singlegearview.cpp index 03a1c3e..9c82168 100644 --- a/armoury/src/singlegearview.cpp +++ b/armoury/src/singlegearview.cpp @@ -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(); diff --git a/common/include/quaternionedit.h b/common/include/quaternionedit.h index 3550f09..741f9a2 100644 --- a/common/include/quaternionedit.h +++ b/common/include/quaternionedit.h @@ -22,7 +22,7 @@ Q_SIGNALS: private: struct { - QDoubleSpinBox *x, *y, *z; + QDoubleSpinBox *x = nullptr, *y = nullptr, *z = nullptr; } spinBoxes; glm::quat &quat; diff --git a/karuku/include/mainwindow.h b/karuku/include/mainwindow.h index 25dabda..591f45f 100644 --- a/karuku/include/mainwindow.h +++ b/karuku/include/mainwindow.h @@ -12,7 +12,7 @@ class MainWindow : public NovusMainWindow Q_OBJECT public: - MainWindow(GameData *data); + explicit MainWindow(GameData *data); private: GameData *data = nullptr; diff --git a/mdlviewer/include/mainwindow.h b/mdlviewer/include/mainwindow.h index f738254..ee5a751 100644 --- a/mdlviewer/include/mainwindow.h +++ b/mdlviewer/include/mainwindow.h @@ -14,7 +14,7 @@ class MainWindow : public NovusMainWindow Q_OBJECT public: - MainWindow(GameData *data); + explicit MainWindow(GameData *data); protected: void setupFileMenu(QMenu *menu) override; diff --git a/parts/cmp/cmppart.cpp b/parts/cmp/cmppart.cpp index 5a37987..d8b3084 100644 --- a/parts/cmp/cmppart.cpp +++ b/parts/cmp/cmppart.cpp @@ -25,8 +25,9 @@ const std::vector 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); diff --git a/parts/cmp/cmppart.h b/parts/cmp/cmppart.h index bc8f913..c9f6478 100644 --- a/parts/cmp/cmppart.h +++ b/parts/cmp/cmppart.h @@ -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; diff --git a/parts/exd/exdpart.cpp b/parts/exd/exdpart.cpp index 4b47449..c095621 100644 --- a/parts/exd/exdpart.cpp +++ b/parts/exd/exdpart.cpp @@ -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; } diff --git a/parts/exd/exdpart.h b/parts/exd/exdpart.h index e27373a..66924ca 100644 --- a/parts/exd/exdpart.h +++ b/parts/exd/exdpart.h @@ -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 cachedExcelSheets; Language getSuitableLanguage(physis_EXH *pExh); diff --git a/parts/hex/document/qhexdocument.cpp b/parts/hex/document/qhexdocument.cpp index 2b6ca48..2ce1b7b 100644 --- a/parts/hex/document/qhexdocument.cpp +++ b/parts/hex/document/qhexdocument.cpp @@ -5,7 +5,6 @@ #include #include #include -#include QHexDocument::QHexDocument(QHexBuffer *buffer, QObject *parent) : QObject(parent) diff --git a/parts/hex/qhexview.cpp b/parts/hex/qhexview.cpp index 76c9890..c4b5662 100644 --- a/parts/hex/qhexview.cpp +++ b/parts/hex/qhexview.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include diff --git a/parts/mdl/mdlpart.cpp b/parts/mdl/mdlpart.cpp index 25fe1fc..27e6227 100644 --- a/parts/mdl/mdlpart.cpp +++ b/parts/mdl/mdlpart.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -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()); diff --git a/parts/mdl/mdlpart.h b/parts/mdl/mdlpart.h index 15fb410..326fc35 100644 --- a/parts/mdl/mdlpart.h +++ b/parts/mdl/mdlpart.h @@ -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 models; - Renderer *renderer; - VulkanWindow *vkWindow; - StandaloneWindow *standaloneWindow; + Renderer *renderer = nullptr; + VulkanWindow *vkWindow = nullptr; bool firstTimeSkeletonDataCalculated = false; }; \ No newline at end of file diff --git a/parts/shpk/shpkpart.cpp b/parts/shpk/shpkpart.cpp index b9bc085..07442a0 100644 --- a/parts/shpk/shpkpart.cpp +++ b/parts/shpk/shpkpart.cpp @@ -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); diff --git a/parts/sklb/sklbpart.cpp b/parts/sklb/sklbpart.cpp index 3873970..cf64866 100644 --- a/parts/sklb/sklbpart.cpp +++ b/parts/sklb/sklbpart.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #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); diff --git a/parts/sklb/sklbpart.h b/parts/sklb/sklbpart.h index 89d1153..4dc2dd7 100644 --- a/parts/sklb/sklbpart.h +++ b/parts/sklb/sklbpart.h @@ -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); diff --git a/parts/tex/imagelabel.cpp b/parts/tex/imagelabel.cpp index 19c3a49..fef97ea 100644 --- a/parts/tex/imagelabel.cpp +++ b/parts/tex/imagelabel.cpp @@ -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()); } diff --git a/renderer/src/imguipass.h b/renderer/src/imguipass.h index 6ae369b..7ad3c97 100644 --- a/renderer/src/imguipass.h +++ b/renderer/src/imguipass.h @@ -12,7 +12,7 @@ struct RenderTarget; class ImGuiPass { public: - ImGuiPass(Renderer &renderer); + explicit ImGuiPass(Renderer &renderer); ~ImGuiPass(); void render(VkCommandBuffer commandBuffer); diff --git a/sagasu/include/filepropertieswindow.h b/sagasu/include/filepropertieswindow.h index 14f288c..a19be15 100644 --- a/sagasu/include/filepropertieswindow.h +++ b/sagasu/include/filepropertieswindow.h @@ -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; diff --git a/sagasu/include/filetreemodel.h b/sagasu/include/filetreemodel.h index 0ed6f05..13ee532 100644 --- a/sagasu/include/filetreemodel.h +++ b/sagasu/include/filetreemodel.h @@ -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 knownDirHashes; diff --git a/sagasu/include/filetreewindow.h b/sagasu/include/filetreewindow.h index 8c198e7..39be6b1 100644 --- a/sagasu/include/filetreewindow.h +++ b/sagasu/include/filetreewindow.h @@ -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; }; \ No newline at end of file diff --git a/sagasu/include/hashdatabase.h b/sagasu/include/hashdatabase.h index 5bdf3ed..f86bf31 100644 --- a/sagasu/include/hashdatabase.h +++ b/sagasu/include/hashdatabase.h @@ -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 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; diff --git a/sagasu/include/mainwindow.h b/sagasu/include/mainwindow.h index 3302a65..968520d 100644 --- a/sagasu/include/mainwindow.h +++ b/sagasu/include/mainwindow.h @@ -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); }; \ No newline at end of file diff --git a/sagasu/src/filepropertieswindow.cpp b/sagasu/src/filepropertieswindow.cpp index 9a67761..501db69 100644 --- a/sagasu/src/filepropertieswindow.cpp +++ b/sagasu/src/filepropertieswindow.cpp @@ -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); diff --git a/sagasu/src/filetreemodel.cpp b/sagasu/src/filetreemodel.cpp index 199250e..1cd8354 100644 --- a/sagasu/src/filetreemodel.cpp +++ b/sagasu/src/filetreemodel.cpp @@ -6,7 +6,7 @@ #include -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; diff --git a/sagasu/src/filetreewindow.cpp b/sagasu/src/filetreewindow.cpp index 02feb99..161cd39 100644 --- a/sagasu/src/filetreewindow.cpp +++ b/sagasu/src/filetreewindow.cpp @@ -8,10 +8,10 @@ #include #include -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); diff --git a/sagasu/src/hashdatabase.cpp b/sagasu/src/hashdatabase.cpp index 4cacda6..089c73c 100644 --- a/sagasu/src/hashdatabase.cpp +++ b/sagasu/src/hashdatabase.cpp @@ -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("/"))) { diff --git a/sagasu/src/main.cpp b/sagasu/src/main.cpp index 7ab518f..35630c4 100644 --- a/sagasu/src/main.cpp +++ b/sagasu/src/main.cpp @@ -3,7 +3,6 @@ #include -#include #include #include "aboutdata.h" diff --git a/sagasu/src/mainwindow.cpp b/sagasu/src/mainwindow.cpp index a21e5c2..c7bf5bf 100644 --- a/sagasu/src/mainwindow.cpp +++ b/sagasu/src/mainwindow.cpp @@ -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(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();