diff --git a/src/ui/PropertyBrowser/qtworkspaceattribute.cpp b/src/ui/PropertyBrowser/qtworkspaceattribute.cpp index f374558d..d4b7f89f 100644 --- a/src/ui/PropertyBrowser/qtworkspaceattribute.cpp +++ b/src/ui/PropertyBrowser/qtworkspaceattribute.cpp @@ -14,15 +14,18 @@ QWorkspaceAttribute::QWorkspaceAttribute(class WorkSpace* workspace) : workspace_(workspace) { - + if (workspace_) { + filesSeq_ = workspace_->GetFilesSeq(); + } } bool QWorkspaceAttribute::operator==(const QWorkspaceAttribute& other) { - return workspace_ == other.workspace_; + return workspace_ == other.workspace_ && filesSeq_ == other.filesSeq_; } QWorkspaceAttribute& QWorkspaceAttribute::operator=(const QWorkspaceAttribute& other) { workspace_ = other.workspace_; + filesSeq_ = other.filesSeq_; return *this; } diff --git a/src/ui/PropertyBrowser/qtworkspaceattribute.h b/src/ui/PropertyBrowser/qtworkspaceattribute.h index e274565b..397a3ccc 100644 --- a/src/ui/PropertyBrowser/qtworkspaceattribute.h +++ b/src/ui/PropertyBrowser/qtworkspaceattribute.h @@ -45,6 +45,7 @@ #include #include "workspace/FileEntry.h" #include +#include class QWorkspaceAttribute { public: @@ -86,6 +87,8 @@ public: QString GetFileEntryAbsPath(FileEntryType type, int index) const; private: class WorkSpace* workspace_{ nullptr }; + // Snapshot of workspace files change sequence to detect mutations + std::uint64_t filesSeq_{ 0 }; }; diff --git a/src/workspace/WorkSpace.cpp b/src/workspace/WorkSpace.cpp index 72cc419b..a0a40b01 100644 --- a/src/workspace/WorkSpace.cpp +++ b/src/workspace/WorkSpace.cpp @@ -134,6 +134,7 @@ WorkSpace::FileEntryResult WorkSpace::CreateFileEntry(FileEntryType type) { } // push a placeholder; actual filename may be set elsewhere via SetWavePath/SetRDPath/etc vec.push_back(FileEntry{ type, QString() }); + ++filesSeq_; // Notify listeners (e.g., PropertyBrowser) to refresh workspace properties emit FilesChanged(type); return FileEntryResult::Ok; @@ -154,6 +155,7 @@ bool WorkSpace::SetFileEntryCount(FileEntryType type, int count) { } else { vec.resize(count); } + ++filesSeq_; emit FilesChanged(type); return true; } @@ -177,6 +179,7 @@ bool WorkSpace::SetFileEntryPath(FileEntryType type, int index, const QString& p return false; } vec[index].fileName = fileInfo.fileName(); + ++filesSeq_; emit FilesChanged(type); return true; } diff --git a/src/workspace/WorkSpace.h b/src/workspace/WorkSpace.h index 39a7f1eb..80208e62 100644 --- a/src/workspace/WorkSpace.h +++ b/src/workspace/WorkSpace.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -162,13 +163,17 @@ private: osgEarth::Viewpoint homeViewpoint_; bool leaded_{ false }; - std::vector entities_; - OEScene* scene_{ nullptr }; - class Timestep* timestep_{ nullptr }; - class LampStatus* lampStatus_{ nullptr }; - class Entity* trackedEntity_{ nullptr }; + std::vector entities_; + OEScene* scene_{ nullptr }; + class Timestep* timestep_{ nullptr }; + class LampStatus* lampStatus_{ nullptr }; + class Entity* trackedEntity_{ nullptr }; // Stored as file entries under workspace dir, keyed by type std::map> files_; + // Monotonic sequence for file entries changes, used to trigger UI refresh + std::uint64_t filesSeq_{ 0 }; +public: + std::uint64_t GetFilesSeq() const { return filesSeq_; } friend class WorkSpaceXMLWrite; };