DYTSrouce/src/ui/Panel/ImagePanel.cpp

75 lines
1.7 KiB
C++
Raw Normal View History

2025-11-02 08:36:07 +00:00
#include "ui/Panel/ImagePanel.h"
#include "ui/DockWidget.h"
#include "ui/DockTitleBar.h"
#include "common/SpdLogger.h"
#include <QHBoxLayout>
#include <QFileInfo>
#include <QMessageBox>
ImagePanel::ImagePanel(int index, const QString& filePath, QWidget* parent)
: DataPanel(index, FileEntryType::Table, filePath, parent)
{
LOG_INFO("Created ImagePanel {} for file: {}", index, filePath.toStdString());
}
ImagePanel::ImagePanel(int index, std::shared_ptr<FileEntryImage> fileEntry, QWidget* parent)
: DataPanel(index, fileEntry, parent)
{
if (fileEntry) {
LOG_INFO("Created ImagePanel {} for chart: {}", index, fileEntry->GetName().toStdString());
// Override the title with chart name
title_ = QString("Image Panel %1 - %2").arg(index).arg(fileEntry->GetName());
}
else {
LOG_WARN("Created ImagePanel {} with null chart data", index);
}
}
ImagePanel::~ImagePanel()
{
LOG_INFO("Destroyed ImagePanel {}", GetIndex());
}
void ImagePanel::RefreshPanel()
{
// Implement curve-specific refresh logic here
DataPanel::RefreshPanel();
if (auto fileEntry = fileEntry_->AsImage()) {
OnDataPanelUpdated(fileEntry);
}
LOG_INFO("Refreshed ImagePanel {}", GetIndex());
}
void ImagePanel::InitUI()
{
2025-11-02 09:51:46 +00:00
QGridLayout* pMainLyt = new QGridLayout(this);
pMainLyt->setContentsMargins(5, 0, 5, 0);
setLayout(pMainLyt);
2025-11-02 08:36:07 +00:00
}
QString ImagePanel::GetTypeDisplayName() const
{
return "Image";
}
void ImagePanel::OnDataPanelUpdated(FileEntryImage* fileEntry)
{
QString strName = fileEntry->GetName();
updateTitle(strName);
}
void ImagePanel::OnTimeChanged(double time)
{
}
void ImagePanel::updateTitle(const QString & title)
{
if (nullptr != dockWidget_)
{
dockWidget_->setWindowTitle(title);
}
}