Modernize repo

This commit is contained in:
Jeremy Rimpo
2024-07-11 11:41:10 +02:00
committed by Mikaël Capelle
parent 01f774dd9f
commit b876f73f73
12 changed files with 253 additions and 212 deletions
+41
View File
@@ -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']
+7
View File
@@ -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
+16
View File
@@ -0,0 +1,16 @@
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-dependencies: cmake_common uibase bsatk
+16
View File
@@ -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: "."
-42
View File
@@ -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
+7 -7
View File
@@ -4,32 +4,32 @@
<context>
<name>PreviewBsa</name>
<message>
<location filename="previewbsa.cpp" line="71"/>
<location filename="previewbsa.cpp" line="64"/>
<source>Preview BSA</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="previewbsa.cpp" line="81"/>
<location filename="previewbsa.cpp" line="74"/>
<source>Supports previewing contents of Bethesda Archive files, BSAs and BA2s</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="previewbsa.cpp" line="92"/>
<location filename="previewbsa.cpp" line="86"/>
<source>Enable previewing of BSA file contents</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="previewbsa.cpp" line="130"/>
<source>Archive Format: %1 , Compression: %2 , File count: %3 , Version: %4 , Archive type: %5 , Archive flags: %6 , Contents flags: %7</source>
<location filename="previewbsa.cpp" line="148"/>
<source>Archive Format: %1 , Compression: %2 , File count: %3 , Version: %4 , Archive type: %5 , Archive flags: %6</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="previewbsa.cpp" line="133"/>
<location filename="previewbsa.cpp" line="153"/>
<source>yes</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="previewbsa.cpp" line="133"/>
<location filename="previewbsa.cpp" line="153"/>
<source>no</source>
<translation type="unfinished"></translation>
</message>
+126 -127
View File
@@ -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<MOBase::PluginSetting> PreviewBsa::settings() const
{
QList<PluginSetting> result;
result.push_back(PluginSetting(
"enabled", tr("Enable previewing of BSA file contents"), QVariant(true)));
return result;
QList<PluginSetting> result;
result.push_back(PluginSetting(
"enabled", tr("Enable previewing of BSA file contents"), QVariant(true)));
return result;
}
std::set<QString> PreviewBsa::supportedExtensions() const
{
std::set<QString> extensions;
for (const auto& generator : m_PreviewGenerators) {
extensions.insert(generator.first);
}
std::set<QString> 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();
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);
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)
+8 -9
View File
@@ -17,12 +17,11 @@ You should have received a copy of the GNU General Public License
along with bsa Preview plugin. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PREVIEWBSA_H
#define PREVIEWBSA_H
#include <ipluginpreview.h>
#include <functional>
#include <ipluginpreview.h>
#include <bsatk.h>
@@ -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 @@ public:
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 @@ public:
public:
virtual std::set<QString> 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<QString, std::function<QWidget*(const QString&, const QSize&)> > m_PreviewGenerators;
std::map<QString, std::function<QWidget*(const QString&, const QSize&)>>
m_PreviewGenerators;
private:
const MOBase::IOrganizer* m_MOInfo;
QStringList m_Files;
};
#endif // PREVIEWBSA_H
#endif // PREVIEWBSA_H
+3 -2
View File
@@ -8,8 +8,9 @@
#include "simplefiletreeitem.h"
SimpleFileTreeItem::SimpleFileTreeItem(const QVector<QVariant>& data, SimpleFileTreeItem* parent)
: m_itemData(data), m_parentItem(parent)
SimpleFileTreeItem::SimpleFileTreeItem(const QVector<QVariant>& data,
SimpleFileTreeItem* parent)
: m_itemData(data), m_parentItem(parent)
{}
SimpleFileTreeItem::~SimpleFileTreeItem()
+3 -2
View File
@@ -7,7 +7,8 @@
class SimpleFileTreeItem
{
public:
explicit SimpleFileTreeItem(const QVector<QVariant>& data, SimpleFileTreeItem* parentItem = nullptr);
explicit SimpleFileTreeItem(const QVector<QVariant>& data,
SimpleFileTreeItem* parentItem = nullptr);
~SimpleFileTreeItem();
void appendChild(SimpleFileTreeItem* child);
@@ -26,4 +27,4 @@ private:
SimpleFileTreeItem* m_parentItem;
};
#endif // SIMPLEFILETREEITEM_H
#endif // SIMPLEFILETREEITEM_H
+19 -17
View File
@@ -8,18 +8,18 @@
#include "simplefiletreemodel.h"
#include "simplefiletreeitem.h"
#include <QStringList>
#include <QDir>
#include <QFileIconProvider>
#include <QStringList>
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<SimpleFileTreeItem*>(index.internalPointer());
SimpleFileTreeItem* childItem =
static_cast<SimpleFileTreeItem*>(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<QVariant> 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;
}
}
+7 -6
View File
@@ -2,11 +2,11 @@
#define SIMPLEFILETREEMODEL_H
#include <QAbstractItemModel>
#include <QIcon>
#include <QLineEdit>
#include <QModelIndex>
#include <QVariant>
#include <QIcon>
#include <filterwidget.h>
#include <QLineEdit>
using namespace MOBase;
@@ -26,15 +26,16 @@ public:
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 @@ private:
QIcon m_FolderIcon;
};
#endif // SIMPLEFILETREEMODEL_H
#endif // SIMPLEFILETREEMODEL_H