diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..6098e1f --- /dev/null +++ b/.clang-format @@ -0,0 +1,41 @@ +--- +# We'll use defaults from the LLVM style, but with 4 columns indentation. +BasedOnStyle: LLVM +IndentWidth: 2 +--- +Language: Cpp +DeriveLineEnding: false +UseCRLF: true +DerivePointerAlignment: false +PointerAlignment: Left +AlignConsecutiveAssignments: true +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Empty +AlwaysBreakTemplateDeclarations: Yes +AccessModifierOffset: -2 +AlignTrailingComments: true +SpacesBeforeTrailingComments: 2 +NamespaceIndentation: Inner +MaxEmptyLinesToKeep: 1 +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: true + AfterControlStatement: false + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: true +ColumnLimit: 88 +ForEachMacros: ['Q_FOREACH', 'foreach'] diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f869712 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized and converted +# to native line endings on checkout. +*.cpp text eol=crlf +*.h text eol=crlf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4ad948d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,17 @@ +name: Build Preview BSA Plugin + +on: + push: + branches: master + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: windows-2022 + steps: + - name: Build Preview BSA Plugin + uses: ModOrganizer2/build-with-mob-action@master + with: + mo2-third-parties: zlib boost lz4 DirectXTex + mo2-dependencies: cmake_common uibase bsatk diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..8de4aa2 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,16 @@ +name: Lint Preview BSA Plugin + +on: + push: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Check format + uses: ModOrganizer2/check-formatting-action@master + with: + check-path: "." diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 50523f5..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: 1.0.{build} -skip_branch_with_pr: true -image: Visual Studio 2019 -environment: - WEBHOOK_URL: - secure: gOKbXaZM9ImtMD5XrYITvdyZUW/az082G9OIN1EC1Vbg57wBaeLhi49uGjxPw5GVujHku6kxN6ab89zhbS5GVeluR76GM83IbKV4Sh7udXzoYZZdg6YudtYHzdhCgUeiedpswbuczTq9ceIkkfSEWZuh/lMAAVVwvcGsJAnoPFw= -build: - parallel: true -build_script: -- pwsh: >- - $ErrorActionPreference = 'Stop' - - git clone --depth=1 --no-single-branch https://github.com/ModOrganizer2/modorganizer-umbrella.git c:\projects\modorganizer-umbrella - - New-Item -ItemType Directory -Path c:\projects\modorganizer-build - - cd c:\projects\modorganizer-umbrella - - ($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH -eq $null) ? ($branch = $env:APPVEYOR_REPO_BRANCH) : ($branch = $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH) - - git checkout $(git show-ref --verify --quiet refs/remotes/origin/${branch} || echo '-b') ${branch} - - C:\Python37-x64\python.exe unimake.py -d c:\projects\modorganizer-build -s Appveyor_Build=True ${env:APPVEYOR_PROJECT_NAME} - - if($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode ) } -artifacts: - - path: vsbuild\src\RelWithDebInfo\preview_bsa.dll - name: preview_bsa_dll - - path: vsbuild\src\RelWithDebInfo\preview_bsa.pdb - name: preview_bsa_pdb - - path: vsbuild\src\RelWithDebInfo\preview_bsa.lib - name: preview_bsa_lib -on_success: - - ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER - - ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1 - - ps: ./send.ps1 success $env:WEBHOOK_URL -on_failure: - - ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER - - ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stdout.log - - ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stderr.log - - ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1 - - ps: ./send.ps1 failure $env:WEBHOOK_URL \ No newline at end of file diff --git a/src/preview_bsa_en.ts b/src/preview_bsa_en.ts index 552770a..7cb073c 100644 --- a/src/preview_bsa_en.ts +++ b/src/preview_bsa_en.ts @@ -4,32 +4,32 @@ PreviewBsa - + Preview BSA - + Supports previewing contents of Bethesda Archive files, BSAs and BA2s - + Enable previewing of BSA file contents - - Archive Format: %1 , Compression: %2 , File count: %3 , Version: %4 , Archive type: %5 , Archive flags: %6 , Contents flags: %7 + + Archive Format: %1 , Compression: %2 , File count: %3 , Version: %4 , Archive type: %5 , Archive flags: %6 - + yes - + no diff --git a/src/previewbsa.cpp b/src/previewbsa.cpp index c50f548..6a467ed 100644 --- a/src/previewbsa.cpp +++ b/src/previewbsa.cpp @@ -43,191 +43,190 @@ PreviewBsa::PreviewBsa() : m_MOInfo(nullptr) {} bool PreviewBsa::init(IOrganizer* moInfo) { - m_MOInfo = moInfo; + m_MOInfo = moInfo; - auto bsaPreview = std::bind(&PreviewBsa::genBsaPreview, this, std::placeholders::_1, - std::placeholders::_2); + auto bsaPreview = std::bind(&PreviewBsa::genBsaPreview, this, std::placeholders::_1, + std::placeholders::_2); - m_PreviewGenerators["bsa"] = bsaPreview; - m_PreviewGenerators["ba2"] = bsaPreview; + m_PreviewGenerators["bsa"] = bsaPreview; + m_PreviewGenerators["ba2"] = bsaPreview; - return true; + return true; } QString PreviewBsa::name() const { - return "Preview Bsa"; + return "Preview Bsa"; } QString PreviewBsa::localizedName() const { - return tr("Preview BSA"); + return tr("Preview BSA"); } QString PreviewBsa::author() const { - return "AL12 & MO2 Team"; + return "AL12 & MO2 Team"; } QString PreviewBsa::description() const { - return tr("Supports previewing contents of Bethesda Archive files, BSAs and BA2s"); + return tr("Supports previewing contents of Bethesda Archive files, BSAs and BA2s"); } MOBase::VersionInfo PreviewBsa::version() const { - return VersionInfo(1, 1, 0, VersionInfo::RELEASE_FINAL); + return VersionInfo(1, 1, 0, VersionInfo::RELEASE_FINAL); } QList PreviewBsa::settings() const { - QList result; - result.push_back(PluginSetting( - "enabled", tr("Enable previewing of BSA file contents"), QVariant(true))); - return result; + QList result; + result.push_back(PluginSetting( + "enabled", tr("Enable previewing of BSA file contents"), QVariant(true))); + return result; } std::set PreviewBsa::supportedExtensions() const { - std::set extensions; - for (const auto& generator : m_PreviewGenerators) { - extensions.insert(generator.first); - } + std::set extensions; + for (const auto& generator : m_PreviewGenerators) { + extensions.insert(generator.first); + } - return extensions; + return extensions; } QWidget* PreviewBsa::genFilePreview(const QString& fileName, const QSize& maxSize) const { - auto iter = m_PreviewGenerators.find(QFileInfo(fileName).suffix().toLower()); - if (iter != m_PreviewGenerators.end()) { - return iter->second(fileName, maxSize); - } - else { - return nullptr; - } + auto iter = m_PreviewGenerators.find(QFileInfo(fileName).suffix().toLower()); + if (iter != m_PreviewGenerators.end()) { + return iter->second(fileName, maxSize); + } else { + return nullptr; + } } void PreviewBsa::readFiles(const BSA::Folder::Ptr archiveFolder) { - const auto fileCount = archiveFolder->getNumFiles(); - for (unsigned int i = 0; i < fileCount; ++i) { - const BSA::File::Ptr file = archiveFolder->getFile(i); + const auto fileCount = archiveFolder->getNumFiles(); + for (unsigned int i = 0; i < fileCount; ++i) { + const BSA::File::Ptr file = archiveFolder->getFile(i); - m_Files << QString::fromStdString(file->getFilePath()); - } + m_Files << QString::fromStdString(file->getFilePath()); + } - // recurse into subdirectories - const auto dirCount = archiveFolder->getNumSubFolders(); - for (unsigned int i = 0; i < dirCount; ++i) { - const BSA::Folder::Ptr folder = archiveFolder->getSubFolder(i); + // recurse into subdirectories + const auto dirCount = archiveFolder->getNumSubFolders(); + for (unsigned int i = 0; i < dirCount; ++i) { + const BSA::Folder::Ptr folder = archiveFolder->getSubFolder(i); - readFiles(folder); - } + readFiles(folder); + } } QWidget* PreviewBsa::genBsaPreview(const QString& fileName, const QSize&) { - m_Files.clear(); - QWidget* wrapper = new QWidget(); - QVBoxLayout* layout = new QVBoxLayout(); - - QLabel* infoLabel = new QLabel(); - BSA::Archive arch; // bs_archive_auto is easier to use, but is less performant when - // working with memory - BSA::EErrorCode res = arch.read(fileName.toLocal8Bit().constData(), true); - if ((res != BSA::ERROR_NONE) && (res != BSA::ERROR_INVALIDHASHES)) { - log::error("invalid bsa '{}', error {}", fileName, res); - infoLabel->setText("Unable to parse archive. Unrecognized format."); - arch.close(); - return wrapper; - } - const BSA::Folder::Ptr archiveDir = arch.getRoot(); - readFiles(archiveDir); - QString infoString = - tr("Archive Format: %1 , Compression: %2 , File count: %3 , Version: %4 , " - "Archive type: %5 , Archive flags: %6"); - // tr("Archive Format: %1 , Compression: %2 , File count: %3 , Version: %4 , " - // "Archive type: %5 , Archive flags: %6 , Contents flags: %7"); - infoString = infoString.arg(getFormat(arch.getType())) - .arg((arch.getFlags() & 0x00000004) ? tr("yes") : tr("no")) - .arg(m_Files.size()) - .arg(getVersion(arch.getType())) - .arg(arch.getType()) - .arg("0x" + QString::number(arch.getFlags(), 16)); - //.arg("0x" + QString::number(arch.get_file_flags(), 16)); - infoLabel->setText(infoString); - layout->addWidget(infoLabel); - - QTreeView* view = new QTreeView(); - SimpleFileTreeModel* model = new SimpleFileTreeModel(m_Files); - - view->setModel(model); - layout->addWidget(view); - - QLineEdit* lineEdit = new QLineEdit(); - layout->addWidget(lineEdit); - - model->setFilterWidgetEdit(lineEdit); - model->setFilterWidgetList(view); - - view->setSortingEnabled(true); - view->sortByColumn(0, Qt::SortOrder::AscendingOrder); - - wrapper->setLayout(layout); + m_Files.clear(); + QWidget* wrapper = new QWidget(); + QVBoxLayout* layout = new QVBoxLayout(); + + QLabel* infoLabel = new QLabel(); + BSA::Archive arch; // bs_archive_auto is easier to use, but is less performant when + // working with memory + BSA::EErrorCode res = arch.read(fileName.toLocal8Bit().constData(), true); + if ((res != BSA::ERROR_NONE) && (res != BSA::ERROR_INVALIDHASHES)) { + log::error("invalid bsa '{}', error {}", fileName, res); + infoLabel->setText("Unable to parse archive. Unrecognized format."); arch.close(); return wrapper; + } + const BSA::Folder::Ptr archiveDir = arch.getRoot(); + readFiles(archiveDir); + QString infoString = + tr("Archive Format: %1 , Compression: %2 , File count: %3 , Version: %4 , " + "Archive type: %5 , Archive flags: %6"); + // tr("Archive Format: %1 , Compression: %2 , File count: %3 , Version: %4 , " + // "Archive type: %5 , Archive flags: %6 , Contents flags: %7"); + infoString = infoString.arg(getFormat(arch.getType())) + .arg((arch.getFlags() & 0x00000004) ? tr("yes") : tr("no")) + .arg(m_Files.size()) + .arg(getVersion(arch.getType())) + .arg(arch.getType()) + .arg("0x" + QString::number(arch.getFlags(), 16)); + //.arg("0x" + QString::number(arch.get_file_flags(), 16)); + infoLabel->setText(infoString); + layout->addWidget(infoLabel); + + QTreeView* view = new QTreeView(); + SimpleFileTreeModel* model = new SimpleFileTreeModel(m_Files); + + view->setModel(model); + layout->addWidget(view); + + QLineEdit* lineEdit = new QLineEdit(); + layout->addWidget(lineEdit); + + model->setFilterWidgetEdit(lineEdit); + model->setFilterWidgetList(view); + + view->setSortingEnabled(true); + view->sortByColumn(0, Qt::SortOrder::AscendingOrder); + + wrapper->setLayout(layout); + arch.close(); + return wrapper; } QString PreviewBsa::getFormat(ArchiveType type) const { - switch (type) { - case ArchiveType::TYPE_MORROWIND: - return "Morrowind"; - case ArchiveType::TYPE_OBLIVION: - return "Oblivion"; - case ArchiveType::TYPE_FALLOUT3: - return "Fallout 3, New Vegas, Skyrim LE"; - case ArchiveType::TYPE_SKYRIMSE: - return "Skyrim Special Edition"; - case ArchiveType::TYPE_FALLOUT4: - return "Fallout 4"; - case ArchiveType::TYPE_STARFIELD: - return "Starfield"; - case ArchiveType::TYPE_STARFIELD_LZ4_TEXTURE: - return "Starfield DDS LZ4"; - case ArchiveType::TYPE_FALLOUT4NG_7: - case ArchiveType::TYPE_FALLOUT4NG_8: - return "Fallout 4 NextGen"; - default: - throw data_invalid_exception(makeString("invalid type %d", type)); - } + switch (type) { + case ArchiveType::TYPE_MORROWIND: + return "Morrowind"; + case ArchiveType::TYPE_OBLIVION: + return "Oblivion"; + case ArchiveType::TYPE_FALLOUT3: + return "Fallout 3, New Vegas, Skyrim LE"; + case ArchiveType::TYPE_SKYRIMSE: + return "Skyrim Special Edition"; + case ArchiveType::TYPE_FALLOUT4: + return "Fallout 4"; + case ArchiveType::TYPE_STARFIELD: + return "Starfield"; + case ArchiveType::TYPE_STARFIELD_LZ4_TEXTURE: + return "Starfield DDS LZ4"; + case ArchiveType::TYPE_FALLOUT4NG_7: + case ArchiveType::TYPE_FALLOUT4NG_8: + return "Fallout 4 NextGen"; + default: + throw data_invalid_exception(makeString("invalid type %d", type)); + } } BSAULong PreviewBsa::getVersion(ArchiveType type) const { - switch (type) { - case TYPE_MORROWIND: - return 0x100; - case TYPE_OBLIVION: - return 0x67; - case TYPE_FALLOUT3: - return 0x68; - case TYPE_SKYRIMSE: - return 0x69; - case TYPE_FALLOUT4: - return 0x01; - case TYPE_STARFIELD: - return 0x02; - case TYPE_STARFIELD_LZ4_TEXTURE: - return 0x03; - case TYPE_FALLOUT4NG_7: - return 0x07; - case TYPE_FALLOUT4NG_8: - return 0x08; - default: - throw data_invalid_exception(makeString("invalid type %d", type)); - } + switch (type) { + case TYPE_MORROWIND: + return 0x100; + case TYPE_OBLIVION: + return 0x67; + case TYPE_FALLOUT3: + return 0x68; + case TYPE_SKYRIMSE: + return 0x69; + case TYPE_FALLOUT4: + return 0x01; + case TYPE_STARFIELD: + return 0x02; + case TYPE_STARFIELD_LZ4_TEXTURE: + return 0x03; + case TYPE_FALLOUT4NG_7: + return 0x07; + case TYPE_FALLOUT4NG_8: + return 0x08; + default: + throw data_invalid_exception(makeString("invalid type %d", type)); + } } #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) diff --git a/src/previewbsa.h b/src/previewbsa.h index cc7c942..7981d89 100644 --- a/src/previewbsa.h +++ b/src/previewbsa.h @@ -17,12 +17,11 @@ You should have received a copy of the GNU General Public License along with bsa Preview plugin. If not, see . */ - #ifndef PREVIEWBSA_H #define PREVIEWBSA_H -#include #include +#include #include @@ -31,7 +30,7 @@ class PreviewBsa : public MOBase::IPluginPreview Q_OBJECT Q_INTERFACES(MOBase::IPlugin MOBase::IPluginPreview) -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) Q_PLUGIN_METADATA(IID "org.tannin.PreviewBsa" FILE "previewbsa.json") #endif @@ -39,7 +38,7 @@ class PreviewBsa : public MOBase::IPluginPreview PreviewBsa(); public: - virtual bool init(MOBase::IOrganizer *moInfo); + virtual bool init(MOBase::IOrganizer* moInfo); virtual QString name() const; virtual QString localizedName() const; virtual QString author() const; @@ -49,21 +48,21 @@ class PreviewBsa : public MOBase::IPluginPreview public: virtual std::set supportedExtensions() const; - virtual QWidget *genFilePreview(const QString &fileName, const QSize &maxSize) const; + virtual QWidget* genFilePreview(const QString& fileName, const QSize& maxSize) const; private: void readFiles(const BSA::Folder::Ptr folder); - QWidget *genBsaPreview(const QString &fileName, const QSize &maxSize); + QWidget* genBsaPreview(const QString& fileName, const QSize& maxSize); QString getFormat(ArchiveType type) const; BSAULong getVersion(ArchiveType type) const; private: - std::map > m_PreviewGenerators; + std::map> + m_PreviewGenerators; private: const MOBase::IOrganizer* m_MOInfo; QStringList m_Files; - }; -#endif // PREVIEWBSA_H +#endif // PREVIEWBSA_H diff --git a/src/simplefiletreeitem.cpp b/src/simplefiletreeitem.cpp index a29da3d..64fab2a 100644 --- a/src/simplefiletreeitem.cpp +++ b/src/simplefiletreeitem.cpp @@ -8,8 +8,9 @@ #include "simplefiletreeitem.h" -SimpleFileTreeItem::SimpleFileTreeItem(const QVector& data, SimpleFileTreeItem* parent) - : m_itemData(data), m_parentItem(parent) +SimpleFileTreeItem::SimpleFileTreeItem(const QVector& data, + SimpleFileTreeItem* parent) + : m_itemData(data), m_parentItem(parent) {} SimpleFileTreeItem::~SimpleFileTreeItem() diff --git a/src/simplefiletreeitem.h b/src/simplefiletreeitem.h index b979101..79da740 100644 --- a/src/simplefiletreeitem.h +++ b/src/simplefiletreeitem.h @@ -7,7 +7,8 @@ class SimpleFileTreeItem { public: - explicit SimpleFileTreeItem(const QVector& data, SimpleFileTreeItem* parentItem = nullptr); + explicit SimpleFileTreeItem(const QVector& data, + SimpleFileTreeItem* parentItem = nullptr); ~SimpleFileTreeItem(); void appendChild(SimpleFileTreeItem* child); @@ -26,4 +27,4 @@ class SimpleFileTreeItem SimpleFileTreeItem* m_parentItem; }; -#endif // SIMPLEFILETREEITEM_H \ No newline at end of file +#endif // SIMPLEFILETREEITEM_H diff --git a/src/simplefiletreemodel.cpp b/src/simplefiletreemodel.cpp index e011bcd..428cc69 100644 --- a/src/simplefiletreemodel.cpp +++ b/src/simplefiletreemodel.cpp @@ -8,18 +8,18 @@ #include "simplefiletreemodel.h" #include "simplefiletreeitem.h" -#include #include #include +#include SimpleFileTreeModel::SimpleFileTreeModel(const QStringList& data, QObject* parent) - : QAbstractItemModel(parent) + : QAbstractItemModel(parent) { QFileIconProvider* provider = new QFileIconProvider(); - m_FolderIcon = provider->icon(QFileIconProvider::Folder); - m_FileIcon = provider->icon(QFileIconProvider::File); + m_FolderIcon = provider->icon(QFileIconProvider::Folder); + m_FileIcon = provider->icon(QFileIconProvider::File); delete provider; - m_RootItem = new SimpleFileTreeItem({ tr("File Name") }); + m_RootItem = new SimpleFileTreeItem({tr("File Name")}); setupModelData(data, m_RootItem); } @@ -45,8 +45,7 @@ QVariant SimpleFileTreeModel::data(const QModelIndex& index, int role) const if (role == Qt::DecorationRole) { if (item->childCount() > 0) { return m_FolderIcon; - } - else { + } else { return m_FileIcon; } } @@ -66,7 +65,7 @@ Qt::ItemFlags SimpleFileTreeModel::flags(const QModelIndex& index) const } QVariant SimpleFileTreeModel::headerData(int section, Qt::Orientation orientation, - int role) const + int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) return m_RootItem->data(section); @@ -74,7 +73,8 @@ QVariant SimpleFileTreeModel::headerData(int section, Qt::Orientation orientatio return QVariant(); } -QModelIndex SimpleFileTreeModel::index(int row, int column, const QModelIndex& parent) const +QModelIndex SimpleFileTreeModel::index(int row, int column, + const QModelIndex& parent) const { if (!hasIndex(row, column, parent)) return QModelIndex(); @@ -97,7 +97,8 @@ QModelIndex SimpleFileTreeModel::parent(const QModelIndex& index) const if (!index.isValid()) return QModelIndex(); - SimpleFileTreeItem* childItem = static_cast(index.internalPointer()); + SimpleFileTreeItem* childItem = + static_cast(index.internalPointer()); SimpleFileTreeItem* parentItem = childItem->parentItem(); if (parentItem == m_RootItem) @@ -120,18 +121,19 @@ int SimpleFileTreeModel::rowCount(const QModelIndex& parent) const return parentItem->childCount(); } -void SimpleFileTreeModel::setupModelData(const QStringList& lines, SimpleFileTreeItem* parent) +void SimpleFileTreeModel::setupModelData(const QStringList& lines, + SimpleFileTreeItem* parent) { for (QString line : lines) { - auto fullPath = QDir::cleanPath(line); + auto fullPath = QDir::cleanPath(line); QStringList lineEntries = fullPath.split("/"); - auto currentParent = m_RootItem; + auto currentParent = m_RootItem; for (int i = 0; i < lineEntries.count(); i++) { - QString currentEntryName = lineEntries[i]; + QString currentEntryName = lineEntries[i]; SimpleFileTreeItem* currentEntry = nullptr; - //check if item was already added + // check if item was already added if (currentParent->childCount() > 0) { for (auto child : currentParent->children()) { if (child->data(0).toString() == currentEntryName) { @@ -141,7 +143,7 @@ void SimpleFileTreeModel::setupModelData(const QStringList& lines, SimpleFileTre } } - //add tree item if not found + // add tree item if not found if (currentEntry == nullptr) { QVector columnData; columnData.reserve(m_ColumnCount); @@ -150,7 +152,7 @@ void SimpleFileTreeModel::setupModelData(const QStringList& lines, SimpleFileTre currentParent->appendChild(currentEntry); } - //as we go deeper into the path + // as we go deeper into the path currentParent = currentEntry; } } diff --git a/src/simplefiletreemodel.h b/src/simplefiletreemodel.h index 0756dc4..4124cd2 100644 --- a/src/simplefiletreemodel.h +++ b/src/simplefiletreemodel.h @@ -2,11 +2,11 @@ #define SIMPLEFILETREEMODEL_H #include +#include +#include #include #include -#include #include -#include using namespace MOBase; @@ -26,15 +26,16 @@ class SimpleFileTreeModel : public QAbstractItemModel QVariant data(const QModelIndex& index, int role) const override; Qt::ItemFlags flags(const QModelIndex& index) const override; QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const override; + int role = Qt::DisplayRole) const override; QModelIndex index(int row, int column, - const QModelIndex& parent = QModelIndex()) const override; + const QModelIndex& parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex& index) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; private: - //takes a list of relative file paths assumed with the same base folder and generates the filetree model + // takes a list of relative file paths assumed with the same base folder and generates + // the filetree model void setupModelData(const QStringList& lines, SimpleFileTreeItem* parent); const int m_ColumnCount = 1; SimpleFileTreeItem* m_RootItem; @@ -43,4 +44,4 @@ class SimpleFileTreeModel : public QAbstractItemModel QIcon m_FolderIcon; }; -#endif // SIMPLEFILETREEMODEL_H \ No newline at end of file +#endif // SIMPLEFILETREEMODEL_H