modify file changes to ui
This commit is contained in:
parent
252db1fc9f
commit
ddd69461dd
@ -14,15 +14,18 @@
|
|||||||
|
|
||||||
QWorkspaceAttribute::QWorkspaceAttribute(class WorkSpace* workspace)
|
QWorkspaceAttribute::QWorkspaceAttribute(class WorkSpace* workspace)
|
||||||
: workspace_(workspace) {
|
: workspace_(workspace) {
|
||||||
|
if (workspace_) {
|
||||||
|
filesSeq_ = workspace_->GetFilesSeq();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWorkspaceAttribute::operator==(const QWorkspaceAttribute& other) {
|
bool QWorkspaceAttribute::operator==(const QWorkspaceAttribute& other) {
|
||||||
return workspace_ == other.workspace_;
|
return workspace_ == other.workspace_ && filesSeq_ == other.filesSeq_;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWorkspaceAttribute& QWorkspaceAttribute::operator=(const QWorkspaceAttribute& other) {
|
QWorkspaceAttribute& QWorkspaceAttribute::operator=(const QWorkspaceAttribute& other) {
|
||||||
workspace_ = other.workspace_;
|
workspace_ = other.workspace_;
|
||||||
|
filesSeq_ = other.filesSeq_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
#include <osg/Vec3>
|
#include <osg/Vec3>
|
||||||
#include "workspace/FileEntry.h"
|
#include "workspace/FileEntry.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
class QWorkspaceAttribute {
|
class QWorkspaceAttribute {
|
||||||
public:
|
public:
|
||||||
@ -86,6 +87,8 @@ public:
|
|||||||
QString GetFileEntryAbsPath(FileEntryType type, int index) const;
|
QString GetFileEntryAbsPath(FileEntryType type, int index) const;
|
||||||
private:
|
private:
|
||||||
class WorkSpace* workspace_{ nullptr };
|
class WorkSpace* workspace_{ nullptr };
|
||||||
|
// Snapshot of workspace files change sequence to detect mutations
|
||||||
|
std::uint64_t filesSeq_{ 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -134,6 +134,7 @@ WorkSpace::FileEntryResult WorkSpace::CreateFileEntry(FileEntryType type) {
|
|||||||
}
|
}
|
||||||
// push a placeholder; actual filename may be set elsewhere via SetWavePath/SetRDPath/etc
|
// push a placeholder; actual filename may be set elsewhere via SetWavePath/SetRDPath/etc
|
||||||
vec.push_back(FileEntry{ type, QString() });
|
vec.push_back(FileEntry{ type, QString() });
|
||||||
|
++filesSeq_;
|
||||||
// Notify listeners (e.g., PropertyBrowser) to refresh workspace properties
|
// Notify listeners (e.g., PropertyBrowser) to refresh workspace properties
|
||||||
emit FilesChanged(type);
|
emit FilesChanged(type);
|
||||||
return FileEntryResult::Ok;
|
return FileEntryResult::Ok;
|
||||||
@ -154,6 +155,7 @@ bool WorkSpace::SetFileEntryCount(FileEntryType type, int count) {
|
|||||||
} else {
|
} else {
|
||||||
vec.resize(count);
|
vec.resize(count);
|
||||||
}
|
}
|
||||||
|
++filesSeq_;
|
||||||
emit FilesChanged(type);
|
emit FilesChanged(type);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -177,6 +179,7 @@ bool WorkSpace::SetFileEntryPath(FileEntryType type, int index, const QString& p
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
vec[index].fileName = fileInfo.fileName();
|
vec[index].fileName = fileInfo.fileName();
|
||||||
|
++filesSeq_;
|
||||||
emit FilesChanged(type);
|
emit FilesChanged(type);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <cstdint>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <osgEarth/Viewpoint>
|
#include <osgEarth/Viewpoint>
|
||||||
@ -169,6 +170,10 @@ private:
|
|||||||
class Entity* trackedEntity_{ nullptr };
|
class Entity* trackedEntity_{ nullptr };
|
||||||
// Stored as file entries under workspace dir, keyed by type
|
// Stored as file entries under workspace dir, keyed by type
|
||||||
std::map<FileEntryType, std::vector<FileEntry>> files_;
|
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;
|
friend class WorkSpaceXMLWrite;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user