mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-20 19:57:44 +00:00
Add file types icons to the Data Explorer
This commit is contained in:
parent
9d129163bb
commit
d04f20a445
3 changed files with 27 additions and 0 deletions
|
@ -13,4 +13,5 @@ public:
|
||||||
static FileType getFileType(const QString &extension);
|
static FileType getFileType(const QString &extension);
|
||||||
|
|
||||||
static QString getFiletypeName(FileType fileType);
|
static QString getFiletypeName(FileType fileType);
|
||||||
|
static QString getFiletypeIcon(FileType fileType);
|
||||||
};
|
};
|
|
@ -25,6 +25,16 @@ const static QMap<FileType, QString> typeToName{{FileType::Unknown, i18n("Unknow
|
||||||
{FileType::CharaMakeParams, i18n("Chara Make Params")},
|
{FileType::CharaMakeParams, i18n("Chara Make Params")},
|
||||||
{FileType::Skeleton, i18n("Skeleton")}};
|
{FileType::Skeleton, i18n("Skeleton")}};
|
||||||
|
|
||||||
|
const static QMap<FileType, QString> typeToIcon{{FileType::Unknown, i18n("unknown")},
|
||||||
|
{FileType::ExcelList, i18n("x-office-spreadsheet")},
|
||||||
|
{FileType::ExcelHeader, i18n("x-office-spreadsheet")},
|
||||||
|
{FileType::ExcelData, i18n("x-office-spreadsheet")},
|
||||||
|
{FileType::Model, i18n("shape-cuboid-symbolic")},
|
||||||
|
{FileType::Texture, i18n("viewimage-symbolic")},
|
||||||
|
{FileType::ShaderPackage, i18n("paint-pattern-symbolic")},
|
||||||
|
{FileType::CharaMakeParams, i18n("step_object_SoftBody-symbolic")},
|
||||||
|
{FileType::Skeleton, i18n("user-symbolic")}};
|
||||||
|
|
||||||
FileType FileTypes::getFileType(const QString &extension)
|
FileType FileTypes::getFileType(const QString &extension)
|
||||||
{
|
{
|
||||||
return extensionToType.value(extension, FileType::Unknown);
|
return extensionToType.value(extension, FileType::Unknown);
|
||||||
|
@ -34,3 +44,8 @@ QString FileTypes::getFiletypeName(FileType fileType)
|
||||||
{
|
{
|
||||||
return typeToName.value(fileType);
|
return typeToName.value(fileType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString FileTypes::getFiletypeIcon(FileType fileType)
|
||||||
|
{
|
||||||
|
return typeToIcon.value(fileType);
|
||||||
|
}
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
#include "filetreemodel.h"
|
#include "filetreemodel.h"
|
||||||
|
#include "filetypes.h"
|
||||||
#include "physis.hpp"
|
#include "physis.hpp"
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
#include <QIcon>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
|
||||||
FileTreeModel::FileTreeModel(HashDatabase &database, bool showUnknown, const QString &gamePath, GameData *data, QObject *parent)
|
FileTreeModel::FileTreeModel(HashDatabase &database, bool showUnknown, const QString &gamePath, GameData *data, QObject *parent)
|
||||||
|
@ -133,6 +135,15 @@ QVariant FileTreeModel::data(const QModelIndex &index, int role) const
|
||||||
return item->name;
|
return item->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (role == Qt::DecorationRole) {
|
||||||
|
if (item->type == TreeType::Folder) {
|
||||||
|
return QIcon::fromTheme(QStringLiteral("folder-black-symbolic"));
|
||||||
|
} else if (item->type == TreeType::File) {
|
||||||
|
QFileInfo info(item->name);
|
||||||
|
const FileType type = FileTypes::getFileType(info.completeSuffix());
|
||||||
|
|
||||||
|
return QIcon::fromTheme(FileTypes::getFiletypeIcon(type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Reference in a new issue