90 lines
2.5 KiB
C++
90 lines
2.5 KiB
C++
#include "ui/Panel/DataPanel.h"
|
|
#include "ui/DockWidget.h"
|
|
#include "common/SpdLogger.h"
|
|
|
|
#include <QVBoxLayout>
|
|
#include <QLabel>
|
|
#include <QFileInfo>
|
|
#include <QCloseEvent>
|
|
|
|
DataPanel::DataPanel(int index, FileEntryType fileType, const QString& filePath, QWidget* parent)
|
|
: QWidget(parent)
|
|
, index_(index)
|
|
, fileType_(fileType)
|
|
, filePath_(filePath)
|
|
, title_()
|
|
, dockWidget_(nullptr)
|
|
{
|
|
title_ = GenerateTitle();
|
|
InitUI();
|
|
|
|
LOG_INFO("Created DataPanel {} for {} file: {}", index_, FileEntryTypeToString(fileType_), filePath_.toStdString());
|
|
}
|
|
|
|
DataPanel::DataPanel(int index, std::shared_ptr<FileEntry> fileEntry, QWidget* parent)
|
|
: QWidget(parent)
|
|
, index_(index)
|
|
, fileType_(fileEntry->GetType())
|
|
, filePath_(fileEntry->GetPath())
|
|
, title_()
|
|
, dockWidget_(nullptr)
|
|
, fileEntry_(fileEntry)
|
|
{
|
|
}
|
|
|
|
DataPanel::~DataPanel()
|
|
{
|
|
LOG_INFO("Destroyed DataPanel {} ({})", index_, FileEntryTypeToString(fileType_));
|
|
}
|
|
|
|
void DataPanel::closeEvent(QCloseEvent* event)
|
|
{
|
|
emit PanelClosed();
|
|
event->accept();
|
|
}
|
|
|
|
void DataPanel::InitUI()
|
|
{
|
|
// // Create basic layout
|
|
// QVBoxLayout* layout = new QVBoxLayout(this);
|
|
|
|
// // Add placeholder label showing panel information
|
|
// QString typeDisplayName = GetTypeDisplayName();
|
|
// QLabel* infoLabel = new QLabel(QString("Panel %1 (%2)\nFile: %3\n\n%4 Data Area\nPlease inherit this class to implement specific functionality")
|
|
// .arg(index_)
|
|
// .arg(typeDisplayName)
|
|
// .arg(QFileInfo(filePath_).fileName())
|
|
// .arg(typeDisplayName));
|
|
// infoLabel->setAlignment(Qt::AlignCenter);
|
|
// infoLabel->setStyleSheet("QLabel { color: #666; font-size: 12px; padding: 20px; }");
|
|
|
|
// layout->addWidget(infoLabel);
|
|
// setLayout(layout);
|
|
|
|
//RefreshPanel();
|
|
}
|
|
|
|
QString DataPanel::GenerateTitle()
|
|
{
|
|
QFileInfo fileInfo(filePath_);
|
|
QString typeDisplayName = GetTypeDisplayName();
|
|
return QString("%1 Panel %2 - %3").arg(typeDisplayName).arg(index_).arg(fileInfo.baseName());
|
|
}
|
|
|
|
QString DataPanel::GetTypeDisplayName() const
|
|
{
|
|
switch (fileType_) {
|
|
case FileEntryType::Curve:
|
|
return "Curve";
|
|
case FileEntryType::Surface:
|
|
return "Surface";
|
|
case FileEntryType::Table:
|
|
return "Table";
|
|
case FileEntryType::Light:
|
|
return "Light";
|
|
case FileEntryType::Polar:
|
|
return "Polar";
|
|
default:
|
|
return "Unknown";
|
|
}
|
|
} |