summaryrefslogtreecommitdiff
path: root/plugin/src/Caelestia/Models/filesystemmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/src/Caelestia/Models/filesystemmodel.cpp')
-rw-r--r--plugin/src/Caelestia/Models/filesystemmodel.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/plugin/src/Caelestia/Models/filesystemmodel.cpp b/plugin/src/Caelestia/Models/filesystemmodel.cpp
index 90ba5a9..9cebaec 100644
--- a/plugin/src/Caelestia/Models/filesystemmodel.cpp
+++ b/plugin/src/Caelestia/Models/filesystemmodel.cpp
@@ -64,6 +64,14 @@ QString FileSystemEntry::mimeType() const {
return m_mimeType;
}
+void FileSystemEntry::updateRelativePath(const QDir& dir) {
+ const auto relPath = dir.relativeFilePath(m_path);
+ if (m_relativePath != relPath) {
+ m_relativePath = relPath;
+ emit relativePathChanged();
+ }
+}
+
FileSystemModel::FileSystemModel(QObject* parent)
: QAbstractListModel(parent)
, m_recursive(false)
@@ -105,6 +113,11 @@ void FileSystemModel::setPath(const QString& path) {
emit pathChanged();
m_dir.setPath(m_path);
+
+ for (const auto& entry : m_entries) {
+ entry->updateRelativePath(m_dir);
+ }
+
update();
}