summaryrefslogtreecommitdiff
path: root/plugin/src
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-01 16:26:54 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-01 16:26:54 +1000
commit704db7b6a695fe2384c80c262119cb2ef9560925 (patch)
tree89faf8925c291153c63bfd7493b6cb4030cc5948 /plugin/src
parentplugin/cim: better sourceSize (diff)
downloadcaelestia-shell-704db7b6a695fe2384c80c262119cb2ef9560925.tar.gz
caelestia-shell-704db7b6a695fe2384c80c262119cb2ef9560925.tar.bz2
caelestia-shell-704db7b6a695fe2384c80c262119cb2ef9560925.zip
plugin/fsm: only provide modelData role
Diffstat (limited to 'plugin/src')
-rw-r--r--plugin/src/Caelestia/filesystemmodel.cpp37
-rw-r--r--plugin/src/Caelestia/filesystemmodel.hpp10
2 files changed, 6 insertions, 41 deletions
diff --git a/plugin/src/Caelestia/filesystemmodel.cpp b/plugin/src/Caelestia/filesystemmodel.cpp
index a1b35d3..dc6027c 100644
--- a/plugin/src/Caelestia/filesystemmodel.cpp
+++ b/plugin/src/Caelestia/filesystemmodel.cpp
@@ -9,46 +9,21 @@
#include <QImageReader>
int FileSystemModel::rowCount(const QModelIndex& parent) const {
- Q_UNUSED(parent);
+ if (parent != QModelIndex()) {
+ return 0;
+ }
return static_cast<int>(m_entries.size());
}
QVariant FileSystemModel::data(const QModelIndex& index, int role) const {
- if (!index.isValid() || index.row() >= m_entries.size()) {
- return QVariant();
- }
-
- FileSystemEntry* file = m_entries.at(index.row());
- switch (role) {
- case FilePathRole:
- return file->path();
- case RelativeFilePathRole:
- return file->relativePath();
- case FileNameRole:
- return file->name();
- case ParentDirRole:
- return file->parentDir();
- case FileSizeRole:
- return file->size();
- case FileIsDirRole:
- return file->isDir();
- case FileIsImageRole:
- return file->isImage();
- default:
+ if (role != Qt::UserRole || !index.isValid() || index.row() >= m_entries.size()) {
return QVariant();
}
+ return QVariant::fromValue(m_entries.at(index.row()));
}
QHash<int, QByteArray> FileSystemModel::roleNames() const {
- QHash<int, QByteArray> roles;
- roles[FilePathRole] = "filePath";
- roles[RelativeFilePathRole] = "relativeFilePath";
- roles[FileNameRole] = "fileName";
- roles[ParentDirRole] = "parentDir";
- roles[FileSizeRole] = "fileSize";
- roles[FileIsDirRole] = "fileIsDir";
- roles[FileIsImageRole] = "fileIsImage";
- return roles;
+ return {{ Qt::UserRole, "modelData"}};
}
QString FileSystemModel::path() const {
diff --git a/plugin/src/Caelestia/filesystemmodel.hpp b/plugin/src/Caelestia/filesystemmodel.hpp
index 9667beb..77a5826 100644
--- a/plugin/src/Caelestia/filesystemmodel.hpp
+++ b/plugin/src/Caelestia/filesystemmodel.hpp
@@ -63,16 +63,6 @@ class FileSystemModel : public QAbstractListModel {
Q_PROPERTY(QList<FileSystemEntry*> entries READ entries NOTIFY entriesChanged)
public:
- enum Roles {
- FilePathRole = Qt::UserRole + 1,
- RelativeFilePathRole,
- FileNameRole,
- ParentDirRole,
- FileSizeRole,
- FileIsDirRole,
- FileIsImageRole
- };
-
enum Filter {
NoFilter,
Images,