61 lines
2.0 KiB
C++
61 lines
2.0 KiB
C++
#include "panels/DatasetDetailPage.hpp"
|
||
|
||
#include <QButtonGroup>
|
||
#include <QVBoxLayout>
|
||
|
||
#include "Glyphs.hpp"
|
||
#include "PanelHeader.hpp"
|
||
#include "panels/chart/GridDataChartView.hpp"
|
||
#include "panels/chart/RawDataChartView.hpp"
|
||
|
||
namespace geopro::app {
|
||
|
||
namespace {
|
||
constexpr int kGridTabIndex = 1; // 「网格数据」页签在 tabs 中的索引
|
||
}
|
||
|
||
DatasetDetailPage::DatasetDetailPage(QWidget* parent) : QWidget(parent) {
|
||
auto* lay = new QVBoxLayout(this);
|
||
lay->setContentsMargins(0, 0, 0, 0);
|
||
lay->setSpacing(0);
|
||
|
||
rawView_ = new RawDataChartView(this);
|
||
gridView_ = new GridDataChartView(this);
|
||
|
||
const QVector<PanelTab> tabs = {
|
||
{Glyph::Detail, QStringLiteral("原数据"), rawView_, false},
|
||
{Glyph::Dataset, QStringLiteral("网格数据"), gridView_, false},
|
||
};
|
||
const QVector<HeaderAction> actions = {
|
||
{Glyph::Download, QStringLiteral("导出")},
|
||
};
|
||
|
||
auto tabbedPanel = buildTabbedPanel(tabs, actions);
|
||
lay->addWidget(tabbedPanel.container);
|
||
|
||
// 「网格数据」页签首次激活 → 懒加载网格数据(rows 服务端网格化慢,故不随开页同步拉)。
|
||
if (tabbedPanel.tabGroup) {
|
||
connect(tabbedPanel.tabGroup, &QButtonGroup::idClicked, this, [this](int idx) {
|
||
if (idx != kGridTabIndex || gridRequested_ || dsId_.isEmpty()) return;
|
||
gridRequested_ = true;
|
||
emit gridDataNeeded(dsId_, ddCode_);
|
||
});
|
||
}
|
||
}
|
||
|
||
void DatasetDetailPage::setData(const geopro::controller::DatasetDetailController::ChartData& d) {
|
||
dsId_ = d.dsId;
|
||
ddCode_ = d.ddCode;
|
||
gridRequested_ = false; // 新数据集 → 网格数据需重新按需加载
|
||
rawView_->setData(d);
|
||
gridView_->setData(d);
|
||
}
|
||
|
||
void DatasetDetailPage::setGridData(
|
||
const geopro::controller::DatasetDetailController::GridData& d) {
|
||
gridRequested_ = true; // 已加载,切回网格页不再重复请求
|
||
gridView_->setGridData(d.grid, d.gridScale, d.anomalies);
|
||
}
|
||
|
||
} // namespace geopro::app
|