modify file changes to ui

This commit is contained in:
brige 2025-10-12 22:55:13 +08:00
parent 252db1fc9f
commit ddd69461dd
4 changed files with 21 additions and 7 deletions

View File

@ -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;
}

View File

@ -45,6 +45,7 @@
#include <osg/Vec3>
#include "workspace/FileEntry.h"
#include <vector>
#include <cstdint>
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 };
};

View File

@ -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;
}

View File

@ -1,6 +1,7 @@
#pragma once
#include <map>
#include <cstdint>
#include <QObject>
#include <osgEarth/Viewpoint>
@ -169,6 +170,10 @@ private:
class Entity* trackedEntity_{ nullptr };
// Stored as file entries under workspace dir, keyed by type
std::map<FileEntryType, std::vector<FileEntry>> 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;
};