modify datatime
This commit is contained in:
parent
1ac2c4d797
commit
c2c88b4ebc
@ -81,6 +81,13 @@ public:
|
||||
* @brief Refresh panel content (virtual function, implemented by derived classes)
|
||||
*/
|
||||
virtual void RefreshPanel() {}
|
||||
|
||||
/**
|
||||
* @brief Handle time change event (virtual function, implemented by derived classes)
|
||||
* @param time Current time value from Timestep
|
||||
*/
|
||||
virtual void OnTimeChanged(double time) {}
|
||||
|
||||
/**
|
||||
* @brief Initialize UI (virtual function, derived classes implement specific layout)
|
||||
*/
|
||||
|
||||
@ -5,10 +5,12 @@
|
||||
#include "ui/DockTitleBar.h"
|
||||
#include "ui/MainWindow.h"
|
||||
#include "workspace/FileEntry.h"
|
||||
#include "workspace/Timestep.h"
|
||||
#include "common/SpdLogger.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QSet>
|
||||
|
||||
const QString DataPanelManager::PANEL_OBJECT_NAME_PREFIX = "DataPanel_";
|
||||
|
||||
@ -42,6 +44,18 @@ void DataPanelManager::SetWorkspace(WorkSpace* workspace)
|
||||
// Connect new workspace signals
|
||||
if (currentWorkspace_) {
|
||||
connect(currentWorkspace_, &WorkSpace::FilesChanged, this, &DataPanelManager::OnFilesChanged);
|
||||
|
||||
// Connect to Timestep signals if available
|
||||
if (currentWorkspace_->GetTimestep()) {
|
||||
connect(currentWorkspace_->GetTimestep(), &Timestep::TimeChanged, this, &DataPanelManager::OnTimeChanged);
|
||||
}
|
||||
|
||||
// Connect to TimestepChanged signal to handle future Timestep changes
|
||||
connect(currentWorkspace_, &WorkSpace::TimestepChanged, this, [this](Timestep* timestep) {
|
||||
if (timestep) {
|
||||
connect(timestep, &Timestep::TimeChanged, this, &DataPanelManager::OnTimeChanged);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Update all panel types
|
||||
@ -293,12 +307,31 @@ QString DataPanelManager::GeneratePanelObjectName(FileEntryType fileType, int in
|
||||
|
||||
int DataPanelManager::FindNextAvailableIndex(FileEntryType fileType) const
|
||||
{
|
||||
int index = 0;
|
||||
QString baseKey = QString("%1_").arg(FileEntryTypeToString(fileType));
|
||||
QSet<int> usedIndices;
|
||||
QString typeStr = FileEntryTypeToString(fileType);
|
||||
|
||||
while (dataPanels_.contains(baseKey + QString::number(index))) {
|
||||
index++;
|
||||
for (auto it = dataPanels_.constBegin(); it != dataPanels_.constEnd(); ++it) {
|
||||
if (it.value()->GetFileType() == fileType) {
|
||||
usedIndices.insert(it.value()->GetIndex());
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
for (int i = 1; i <= GetMaxPanelCount(); ++i) {
|
||||
if (!usedIndices.contains(i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1; // No available index
|
||||
}
|
||||
|
||||
void DataPanelManager::OnTimeChanged(double time)
|
||||
{
|
||||
// Notify all active panels about time change
|
||||
for (auto it = dataPanels_.constBegin(); it != dataPanels_.constEnd(); ++it) {
|
||||
DataPanel* panel = it.value();
|
||||
if (panel) {
|
||||
panel->OnTimeChanged(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,6 +68,12 @@ public slots:
|
||||
*/
|
||||
void OnPanelClosed();
|
||||
|
||||
/**
|
||||
* @brief Handle time change event from Timestep
|
||||
* @param time Current time value
|
||||
*/
|
||||
void OnTimeChanged(double time);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Update panels for specific file type
|
||||
|
||||
Loading…
Reference in New Issue
Block a user