fix(list): 数据/文件/异常列表退回标准 QListWidget + 写死强选中色
根因: ElaListView 的选中底走 BasicSelectedAlpha, setThemeColor 改它对 ElaListView 不生效(自绘控件坑), 选中色无法变强。与对象树同理, 退回 Qt 原生 QListWidget: - 3 列表 ElaListView+QStandardItemModel → QListWidget+QListWidgetItem(populate/加载更多/点击/勾选 全回退) - applyListSelection: 本地 QSS 写死强调蓝选中(明 #C2D9F2 / 暗 #33527A + 适配文字, :!active 防失焦淡), 与对象树选中色完全一致, 100% 可控、明暗都清晰 - 行为(加载更多/数据集点击/异常勾选显隐)保持
This commit is contained in:
parent
66cf432a98
commit
52bdf054a6
107
src/app/main.cpp
107
src/app/main.cpp
|
|
@ -36,9 +36,8 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QGraphicsOpacityEffect>
|
#include <QGraphicsOpacityEffect>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QModelIndex>
|
#include <QListWidget>
|
||||||
#include <QStandardItem>
|
#include <QListWidgetItem>
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
@ -68,7 +67,6 @@
|
||||||
#include <ElaApplication.h>
|
#include <ElaApplication.h>
|
||||||
#include <ElaCheckBox.h>
|
#include <ElaCheckBox.h>
|
||||||
#include <ElaDef.h>
|
#include <ElaDef.h>
|
||||||
#include <ElaListView.h>
|
|
||||||
#include <ElaTheme.h>
|
#include <ElaTheme.h>
|
||||||
#include <ElaToolButton.h>
|
#include <ElaToolButton.h>
|
||||||
#include <ElaWindow.h>
|
#include <ElaWindow.h>
|
||||||
|
|
@ -544,15 +542,30 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
|
||||||
{{geopro::app::Glyph::Plus, QStringLiteral("新建对象")}}));
|
{{geopro::app::Glyph::Plus, QStringLiteral("新建对象")}}));
|
||||||
auto* leftArea = dockManager->addDockWidget(ads::LeftDockWidgetArea, leftDock);
|
auto* leftArea = dockManager->addDockWidget(ads::LeftDockWidgetArea, leftDock);
|
||||||
|
|
||||||
|
// 列表选中色:写死的强调蓝(明 #C2D9F2 / 暗 #33527A)+ 适配文字,:!active 防失焦变淡;
|
||||||
|
// 与对象树选中色一致。本地 QSS 覆盖全局弱选中色,随主题重设。
|
||||||
|
auto applyListSelection = [](QListWidget* lw) {
|
||||||
|
auto styleIt = [lw]() {
|
||||||
|
const bool dark = geopro::app::isDarkTheme();
|
||||||
|
const QString selBg = dark ? QStringLiteral("#33527A") : QStringLiteral("#C2D9F2");
|
||||||
|
const QString selFg = dark ? QStringLiteral("#E8F1FB") : QStringLiteral("#14385F");
|
||||||
|
lw->setStyleSheet(QStringLiteral("QListWidget::item:selected{ background:%1; color:%2; }"
|
||||||
|
"QListWidget::item:selected:!active{ background:%1;"
|
||||||
|
" color:%2; }")
|
||||||
|
.arg(selBg, selFg));
|
||||||
|
};
|
||||||
|
styleIt();
|
||||||
|
QObject::connect(eTheme, &ElaTheme::themeModeChanged, lw,
|
||||||
|
[styleIt](ElaThemeType::ThemeMode) { styleIt(); });
|
||||||
|
};
|
||||||
|
|
||||||
// 左下 dock:数据真实显示栏(选中测线后列其采集批次=数据集;tab 数据/文件)。
|
// 左下 dock:数据真实显示栏(选中测线后列其采集批次=数据集;tab 数据/文件)。
|
||||||
auto* datasetTabs = new QTabWidget();
|
auto* datasetTabs = new QTabWidget();
|
||||||
auto* datasetList = new ElaListView(); // Fluent 列表(自绘 hover/选中, 随主题)
|
auto* datasetList = new QListWidget();
|
||||||
auto* datasetModel = new QStandardItemModel(datasetList);
|
applyListSelection(datasetList);
|
||||||
datasetList->setModel(datasetModel);
|
|
||||||
datasetTabs->addTab(datasetList, QStringLiteral("数据"));
|
datasetTabs->addTab(datasetList, QStringLiteral("数据"));
|
||||||
auto* fileList = new ElaListView();
|
auto* fileList = new QListWidget();
|
||||||
auto* fileModel = new QStandardItemModel(fileList);
|
applyListSelection(fileList);
|
||||||
fileList->setModel(fileModel);
|
|
||||||
datasetTabs->addTab(fileList, QStringLiteral("文件"));
|
datasetTabs->addTab(fileList, QStringLiteral("文件"));
|
||||||
auto* datasetDock = new ads::CDockWidget(QStringLiteral("数据真实显示栏"));
|
auto* datasetDock = new ads::CDockWidget(QStringLiteral("数据真实显示栏"));
|
||||||
auto* datasetBox = wrapWithHeader(
|
auto* datasetBox = wrapWithHeader(
|
||||||
|
|
@ -565,9 +578,8 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
|
||||||
dockManager->addDockWidget(ads::BottomDockWidgetArea, datasetDock, leftArea);
|
dockManager->addDockWidget(ads::BottomDockWidgetArea, datasetDock, leftArea);
|
||||||
|
|
||||||
// 右上 dock:异常列表 / 对象属性 合并为带 Tab 表头的面板(对齐原型上半)。
|
// 右上 dock:异常列表 / 对象属性 合并为带 Tab 表头的面板(对齐原型上半)。
|
||||||
auto* anomalyList = new ElaListView();
|
auto* anomalyList = new QListWidget();
|
||||||
auto* anomalyModel = new QStandardItemModel(anomalyList);
|
applyListSelection(anomalyList);
|
||||||
anomalyList->setModel(anomalyModel);
|
|
||||||
auto* objAttrLabel = new QLabel(QStringLiteral("(选中对象后显示其属性)"));
|
auto* objAttrLabel = new QLabel(QStringLiteral("(选中对象后显示其属性)"));
|
||||||
objAttrLabel->setWordWrap(true);
|
objAttrLabel->setWordWrap(true);
|
||||||
objAttrLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
objAttrLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
||||||
|
|
@ -727,7 +739,7 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载某数据集到「数据详情 + 异常列表 + 属性」(数据列表单击与启动默认共用)。
|
// 加载某数据集到「数据详情 + 异常列表 + 属性」(数据列表单击与启动默认共用)。
|
||||||
auto loadDataset = [&repo, propLabel, currentDsId, rebuildDetail, anomalyModel, hiddenAnoms,
|
auto loadDataset = [&repo, propLabel, currentDsId, rebuildDetail, anomalyList, hiddenAnoms,
|
||||||
anomalyBadge](const QString& dsId, const QString& name) {
|
anomalyBadge](const QString& dsId, const QString& name) {
|
||||||
if (dsId.isEmpty()) return;
|
if (dsId.isEmpty()) return;
|
||||||
*currentDsId = dsId;
|
*currentDsId = dsId;
|
||||||
|
|
@ -736,8 +748,8 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
|
||||||
const auto anomalies = repo.loadAnomalies(dsId.toStdString());
|
const auto anomalies = repo.loadAnomalies(dsId.toStdString());
|
||||||
hiddenAnoms->clear();
|
hiddenAnoms->clear();
|
||||||
{
|
{
|
||||||
const QSignalBlocker block(anomalyModel); // 重填触发 itemChanged,先屏蔽
|
const QSignalBlocker block(anomalyList); // 重填触发 itemChanged,先屏蔽
|
||||||
geopro::app::populateAnomalyList(anomalyModel, anomalies);
|
geopro::app::populateAnomalyList(anomalyList, anomalies);
|
||||||
}
|
}
|
||||||
// 异常列表 Tab 数量徽标。
|
// 异常列表 Tab 数量徽标。
|
||||||
if (anomalyBadge) {
|
if (anomalyBadge) {
|
||||||
|
|
@ -763,13 +775,14 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
|
||||||
|
|
||||||
// ── 单击左下数据列表的采集批次(DS) → 占位(真实剖面/反演渲染下一阶段接 dd 接口)──
|
// ── 单击左下数据列表的采集批次(DS) → 占位(真实剖面/反演渲染下一阶段接 dd 接口)──
|
||||||
// 接 dd 那轮:把本处占位改为 loadDataset(id, name) 即接通详情渲染,并自动激活 overdrive-A 揭示动画。
|
// 接 dd 那轮:把本处占位改为 loadDataset(id, name) 即接通详情渲染,并自动激活 overdrive-A 揭示动画。
|
||||||
QObject::connect(datasetList, &QAbstractItemView::clicked, datasetList,
|
QObject::connect(datasetList, &QListWidget::itemClicked, datasetList,
|
||||||
[propLabel, detailRendererPtr, detailRenderWindowPtr, &nav](const QModelIndex& idx) {
|
[propLabel, detailRendererPtr, detailRenderWindowPtr, &nav](QListWidgetItem* item) {
|
||||||
if (idx.data(geopro::app::kDsLoadMoreRole).toBool()) {
|
if (item->data(geopro::app::kDsLoadMoreRole).toBool()) {
|
||||||
nav.loadMoreData();
|
nav.loadMoreData();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const QString name = idx.data(Qt::DisplayRole).toString().section('\n', 0, 0);
|
const QString name =
|
||||||
|
item->data(Qt::DisplayRole).toString().section('\n', 0, 0);
|
||||||
detailRendererPtr->RemoveAllViewProps();
|
detailRendererPtr->RemoveAllViewProps();
|
||||||
detailRenderWindowPtr->Render();
|
detailRenderWindowPtr->Render();
|
||||||
propLabel->setText(QStringLiteral(
|
propLabel->setText(QStringLiteral(
|
||||||
|
|
@ -777,8 +790,8 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
|
||||||
});
|
});
|
||||||
|
|
||||||
// ── 异常列表勾选(显隐) → 更新隐藏集 → 重建数据详情 ──
|
// ── 异常列表勾选(显隐) → 更新隐藏集 → 重建数据详情 ──
|
||||||
QObject::connect(anomalyModel, &QStandardItemModel::itemChanged, anomalyList,
|
QObject::connect(anomalyList, &QListWidget::itemChanged, anomalyList,
|
||||||
[hiddenAnoms, rebuildDetail](QStandardItem* item) {
|
[hiddenAnoms, rebuildDetail](QListWidgetItem* item) {
|
||||||
const int idx = item->data(geopro::app::kAnomalyIndexRole).toInt();
|
const int idx = item->data(geopro::app::kAnomalyIndexRole).toInt();
|
||||||
if (item->checkState() == Qt::Checked)
|
if (item->checkState() == Qt::Checked)
|
||||||
hiddenAnoms->erase(idx);
|
hiddenAnoms->erase(idx);
|
||||||
|
|
@ -891,20 +904,18 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
|
||||||
|
|
||||||
// ── 控制器 ↔ UI 信号接线(导航壳)──────────────────────────────────────
|
// ── 控制器 ↔ UI 信号接线(导航壳)──────────────────────────────────────
|
||||||
// "加载更多"行:列表末尾若已加载数 < 总数,放一行可点击的"加载更多(已/共)"。
|
// "加载更多"行:列表末尾若已加载数 < 总数,放一行可点击的"加载更多(已/共)"。
|
||||||
auto removeLoadMore = [](QStandardItemModel* mdl) {
|
auto removeLoadMore = [](QListWidget* lw) {
|
||||||
const int n = mdl->rowCount();
|
if (lw->count() > 0 &&
|
||||||
if (n > 0 && mdl->item(n - 1)->data(geopro::app::kDsLoadMoreRole).toBool())
|
lw->item(lw->count() - 1)->data(geopro::app::kDsLoadMoreRole).toBool())
|
||||||
mdl->removeRow(n - 1);
|
delete lw->takeItem(lw->count() - 1);
|
||||||
};
|
};
|
||||||
auto addLoadMore = [](QStandardItemModel* mdl, int total) {
|
auto addLoadMore = [](QListWidget* lw, int total) {
|
||||||
const int loaded = mdl->rowCount();
|
const int loaded = lw->count();
|
||||||
if (loaded < total) {
|
if (loaded < total) {
|
||||||
auto* it = new QStandardItem(QStringLiteral("加载更多(%1/%2)").arg(loaded).arg(total));
|
auto* m = new QListWidgetItem(QStringLiteral("加载更多(%1/%2)").arg(loaded).arg(total), lw);
|
||||||
it->setData(true, geopro::app::kDsLoadMoreRole);
|
m->setData(geopro::app::kDsLoadMoreRole, true);
|
||||||
it->setTextAlignment(Qt::AlignCenter);
|
m->setTextAlignment(Qt::AlignCenter);
|
||||||
it->setForeground(QColor("#2D6CB5"));
|
m->setForeground(QColor("#2D6CB5"));
|
||||||
it->setEditable(false);
|
|
||||||
mdl->appendRow(it);
|
|
||||||
}
|
}
|
||||||
return loaded;
|
return loaded;
|
||||||
};
|
};
|
||||||
|
|
@ -943,42 +954,42 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
|
||||||
topBar->setProjects(list, cur, total > static_cast<int>(list.size()));
|
topBar->setProjects(list, cur, total > static_cast<int>(list.size()));
|
||||||
});
|
});
|
||||||
QObject::connect(&nav, &geopro::controller::WorkbenchNavController::structureLoaded, objectTree,
|
QObject::connect(&nav, &geopro::controller::WorkbenchNavController::structureLoaded, objectTree,
|
||||||
[objectTree, datasetModel, fileModel, datasetTitle, datasetTabs](
|
[objectTree, datasetList, fileList, datasetTitle, datasetTabs](
|
||||||
const QString& projectName,
|
const QString& projectName,
|
||||||
const std::vector<geopro::data::StructNode>& nodes) {
|
const std::vector<geopro::data::StructNode>& nodes) {
|
||||||
objectTree->setStructure(projectName, nodes);
|
objectTree->setStructure(projectName, nodes);
|
||||||
datasetModel->clear();
|
datasetList->clear();
|
||||||
fileModel->clear();
|
fileList->clear();
|
||||||
if (datasetTitle) datasetTitle->setText(QStringLiteral("数据集显示栏"));
|
if (datasetTitle) datasetTitle->setText(QStringLiteral("数据集显示栏"));
|
||||||
datasetTabs->setTabText(0, QStringLiteral("数据"));
|
datasetTabs->setTabText(0, QStringLiteral("数据"));
|
||||||
datasetTabs->setTabText(1, QStringLiteral("文件"));
|
datasetTabs->setTabText(1, QStringLiteral("文件"));
|
||||||
});
|
});
|
||||||
QObject::connect(&nav, &geopro::controller::WorkbenchNavController::datasetsLoaded, datasetList,
|
QObject::connect(&nav, &geopro::controller::WorkbenchNavController::datasetsLoaded, datasetList,
|
||||||
[removeLoadMore, addLoadMore, datasetModel, datasetTitle, datasetTabs](
|
[removeLoadMore, addLoadMore, datasetList, datasetTitle, datasetTabs](
|
||||||
const QString&, const std::vector<geopro::data::DsRow>& rows, int total,
|
const QString&, const std::vector<geopro::data::DsRow>& rows, int total,
|
||||||
bool append) {
|
bool append) {
|
||||||
removeLoadMore(datasetModel);
|
removeLoadMore(datasetList);
|
||||||
geopro::app::populateDatasetList(datasetModel, rows, append);
|
geopro::app::populateDatasetList(datasetList, rows, append);
|
||||||
const int loaded = addLoadMore(datasetModel, total);
|
const int loaded = addLoadMore(datasetList, total);
|
||||||
if (datasetTitle) datasetTitle->setText(QStringLiteral("数据集显示栏"));
|
if (datasetTitle) datasetTitle->setText(QStringLiteral("数据集显示栏"));
|
||||||
datasetTabs->setTabText(
|
datasetTabs->setTabText(
|
||||||
0, total > 0 ? QStringLiteral("数据 (%1/%2)").arg(loaded).arg(total)
|
0, total > 0 ? QStringLiteral("数据 (%1/%2)").arg(loaded).arg(total)
|
||||||
: QStringLiteral("数据"));
|
: QStringLiteral("数据"));
|
||||||
});
|
});
|
||||||
QObject::connect(&nav, &geopro::controller::WorkbenchNavController::filesLoaded, fileList,
|
QObject::connect(&nav, &geopro::controller::WorkbenchNavController::filesLoaded, fileList,
|
||||||
[removeLoadMore, addLoadMore, fileModel, datasetTabs](
|
[removeLoadMore, addLoadMore, fileList, datasetTabs](
|
||||||
const QString&, const std::vector<geopro::data::DsRow>& rows, int total,
|
const QString&, const std::vector<geopro::data::DsRow>& rows, int total,
|
||||||
bool append) {
|
bool append) {
|
||||||
removeLoadMore(fileModel);
|
removeLoadMore(fileList);
|
||||||
geopro::app::populateFileList(fileModel, rows, append);
|
geopro::app::populateFileList(fileList, rows, append);
|
||||||
const int loaded = addLoadMore(fileModel, total);
|
const int loaded = addLoadMore(fileList, total);
|
||||||
datasetTabs->setTabText(
|
datasetTabs->setTabText(
|
||||||
1, total > 0 ? QStringLiteral("文件 (%1/%2)").arg(loaded).arg(total)
|
1, total > 0 ? QStringLiteral("文件 (%1/%2)").arg(loaded).arg(total)
|
||||||
: QStringLiteral("文件"));
|
: QStringLiteral("文件"));
|
||||||
});
|
});
|
||||||
QObject::connect(fileList, &QAbstractItemView::clicked, fileList,
|
QObject::connect(fileList, &QListWidget::itemClicked, fileList,
|
||||||
[&nav](const QModelIndex& idx) {
|
[&nav](QListWidgetItem* item) {
|
||||||
if (idx.data(geopro::app::kDsLoadMoreRole).toBool()) nav.loadMoreFiles();
|
if (item->data(geopro::app::kDsLoadMoreRole).toBool()) nav.loadMoreFiles();
|
||||||
});
|
});
|
||||||
QObject::connect(&nav, &geopro::controller::WorkbenchNavController::loadFailed, objectTree,
|
QObject::connect(&nav, &geopro::controller::WorkbenchNavController::loadFailed, objectTree,
|
||||||
[objectTree, &window](const QString& stage, const QString& msg) {
|
[objectTree, &window](const QString& stage, const QString& msg) {
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QListWidgetItem>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QStandardItem>
|
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "model/ColorScale.hpp"
|
#include "model/ColorScale.hpp"
|
||||||
|
|
@ -54,10 +54,10 @@ QPixmap swatch(const std::string& colorStr)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void populateAnomalyList(QStandardItemModel* model, const std::vector<geopro::core::Anomaly>& anomalies)
|
void populateAnomalyList(QListWidget* list, const std::vector<geopro::core::Anomaly>& anomalies)
|
||||||
{
|
{
|
||||||
if (!model) return;
|
if (!list) return;
|
||||||
model->clear();
|
list->clear();
|
||||||
for (std::size_t i = 0; i < anomalies.size(); ++i) {
|
for (std::size_t i = 0; i < anomalies.size(); ++i) {
|
||||||
const auto& a = anomalies[i];
|
const auto& a = anomalies[i];
|
||||||
const QString name = QString::fromStdString(a.name.empty() ? "异常" : a.name);
|
const QString name = QString::fromStdString(a.name.empty() ? "异常" : a.name);
|
||||||
|
|
@ -66,12 +66,10 @@ void populateAnomalyList(QStandardItemModel* model, const std::vector<geopro::co
|
||||||
if (!type.isEmpty()) text += QStringLiteral("(%1)").arg(type);
|
if (!type.isEmpty()) text += QStringLiteral("(%1)").arg(type);
|
||||||
text += QStringLiteral("\n%1").arg(summarize(a));
|
text += QStringLiteral("\n%1").arg(summarize(a));
|
||||||
|
|
||||||
auto* item = new QStandardItem(QIcon(swatch(a.lineColor)), text);
|
auto* item = new QListWidgetItem(QIcon(swatch(a.lineColor)), text, list);
|
||||||
item->setEditable(false);
|
item->setData(kAnomalyIndexRole, static_cast<int>(i));
|
||||||
item->setData(static_cast<int>(i), kAnomalyIndexRole);
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||||
item->setCheckable(true);
|
|
||||||
item->setCheckState(Qt::Checked); // 默认显示
|
item->setCheckState(Qt::Checked); // 默认显示
|
||||||
model->appendRow(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "model/Anomaly.hpp"
|
#include "model/Anomaly.hpp"
|
||||||
|
|
||||||
class QStandardItemModel;
|
class QListWidget;
|
||||||
|
|
||||||
namespace geopro::app {
|
namespace geopro::app {
|
||||||
|
|
||||||
|
|
@ -14,6 +14,6 @@ constexpr int kAnomalyIndexRole = 0x0100; // Qt::UserRole
|
||||||
// 派生「位置 Xm · 深 Ym · 尺寸 Zm」(由 location.coordinate 质心/包络算)。
|
// 派生「位置 Xm · 深 Ym · 尺寸 Zm」(由 location.coordinate 质心/包络算)。
|
||||||
// 条目可勾选:勾=显示(默认全勾);勾选状态变化由调用方连接驱动该异常 actor 显隐。
|
// 条目可勾选:勾=显示(默认全勾);勾选状态变化由调用方连接驱动该异常 actor 显隐。
|
||||||
// 清空旧条目后重填。
|
// 清空旧条目后重填。
|
||||||
void populateAnomalyList(QStandardItemModel* model, const std::vector<geopro::core::Anomaly>& anomalies);
|
void populateAnomalyList(QListWidget* list, const std::vector<geopro::core::Anomaly>& anomalies);
|
||||||
|
|
||||||
} // namespace geopro::app
|
} // namespace geopro::app
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#include "panels/DatasetListPanel.hpp"
|
#include "panels/DatasetListPanel.hpp"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QStandardItem>
|
#include <QListWidget>
|
||||||
#include <QStandardItemModel>
|
#include <QListWidgetItem>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace geopro::app {
|
namespace geopro::app {
|
||||||
|
|
@ -16,34 +16,29 @@ QString humanSize(long long b) {
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void populateDatasetList(QStandardItemModel* model, const std::vector<geopro::data::DsRow>& rows,
|
void populateDatasetList(QListWidget* list, const std::vector<geopro::data::DsRow>& rows, bool append) {
|
||||||
bool append) {
|
if (!list) return;
|
||||||
if (!model) return;
|
if (!append) list->clear();
|
||||||
if (!append) model->clear();
|
|
||||||
for (const auto& d : rows) {
|
for (const auto& d : rows) {
|
||||||
QString text = QString::fromStdString(d.dsName);
|
QString text = QString::fromStdString(d.dsName);
|
||||||
QString sub = QString::fromStdString(d.createTime); // 名称下先创建时间
|
QString sub = QString::fromStdString(d.createTime); // 名称下先创建时间
|
||||||
if (!d.typeName.empty())
|
if (!d.typeName.empty())
|
||||||
sub += QStringLiteral(" · %1").arg(QString::fromStdString(d.typeName)); // 再跟类型
|
sub += QStringLiteral(" · %1").arg(QString::fromStdString(d.typeName)); // 再跟类型
|
||||||
if (!sub.isEmpty()) text += QStringLiteral("\n%1").arg(sub);
|
if (!sub.isEmpty()) text += QStringLiteral("\n%1").arg(sub);
|
||||||
auto* item = new QStandardItem(text);
|
auto* item = new QListWidgetItem(text, list);
|
||||||
item->setEditable(false);
|
item->setData(kDsIdRole, QString::fromStdString(d.id));
|
||||||
item->setData(QString::fromStdString(d.id), kDsIdRole);
|
item->setData(kDsDdTypeRole, QString::fromStdString(d.ddCode));
|
||||||
item->setData(QString::fromStdString(d.ddCode), kDsDdTypeRole);
|
|
||||||
model->appendRow(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void populateFileList(QStandardItemModel* model, const std::vector<geopro::data::DsRow>& rows,
|
void populateFileList(QListWidget* list, const std::vector<geopro::data::DsRow>& rows, bool append) {
|
||||||
bool append) {
|
if (!list) return;
|
||||||
if (!model) return;
|
if (!append) list->clear();
|
||||||
if (!append) model->clear();
|
|
||||||
if (!append && rows.empty()) {
|
if (!append && rows.empty()) {
|
||||||
auto* hint = new QStandardItem(QStringLiteral("(暂无文件)"));
|
auto* hint = new QListWidgetItem(QStringLiteral("(暂无文件)"), list);
|
||||||
hint->setFlags(Qt::NoItemFlags);
|
hint->setFlags(Qt::NoItemFlags);
|
||||||
hint->setForeground(QColor("#9AA6B6"));
|
hint->setForeground(QColor("#9AA6B6"));
|
||||||
hint->setTextAlignment(Qt::AlignCenter);
|
hint->setTextAlignment(Qt::AlignCenter);
|
||||||
model->appendRow(hint);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const auto& d : rows) {
|
for (const auto& d : rows) {
|
||||||
|
|
@ -52,11 +47,9 @@ void populateFileList(QStandardItemModel* model, const std::vector<geopro::data:
|
||||||
QString sub = QString::fromStdString(d.createTime); // 名称下先创建时间
|
QString sub = QString::fromStdString(d.createTime); // 名称下先创建时间
|
||||||
sub += QStringLiteral(" · %1").arg(humanSize(d.fileSize)); // 再跟大小
|
sub += QStringLiteral(" · %1").arg(humanSize(d.fileSize)); // 再跟大小
|
||||||
const QString text = fname + QStringLiteral("\n%1").arg(sub);
|
const QString text = fname + QStringLiteral("\n%1").arg(sub);
|
||||||
auto* item = new QStandardItem(text);
|
auto* item = new QListWidgetItem(text, list);
|
||||||
item->setEditable(false);
|
item->setData(kDsIdRole, QString::fromStdString(d.id));
|
||||||
item->setData(QString::fromStdString(d.id), kDsIdRole);
|
item->setData(kDsFileUrlRole, QString::fromStdString(d.fileUrl));
|
||||||
item->setData(QString::fromStdString(d.fileUrl), kDsFileUrlRole);
|
|
||||||
model->appendRow(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "repo/RepoTypes.hpp"
|
#include "repo/RepoTypes.hpp"
|
||||||
|
|
||||||
class QStandardItemModel;
|
class QListWidget;
|
||||||
|
|
||||||
namespace geopro::app {
|
namespace geopro::app {
|
||||||
|
|
||||||
|
|
@ -13,11 +13,9 @@ constexpr int kDsDdTypeRole = 0x0101; // Qt::UserRole + 1
|
||||||
constexpr int kDsFileUrlRole = 0x0102; // Qt::UserRole + 2(文件下载 url,备用)
|
constexpr int kDsFileUrlRole = 0x0102; // Qt::UserRole + 2(文件下载 url,备用)
|
||||||
constexpr int kDsLoadMoreRole = 0x0103; // 标记"加载更多"行
|
constexpr int kDsLoadMoreRole = 0x0103; // 标记"加载更多"行
|
||||||
|
|
||||||
// 数据页签:每条 = dsName +(类型名);UserRole 存 dsId、+1 存 ddCode。填入标准 model。
|
// 数据页签:每条 = dsName +(类型名);UserRole 存 dsId、+1 存 ddCode。
|
||||||
void populateDatasetList(QStandardItemModel* model, const std::vector<geopro::data::DsRow>& rows,
|
void populateDatasetList(QListWidget* list, const std::vector<geopro::data::DsRow>& rows, bool append);
|
||||||
bool append);
|
|
||||||
// 文件页签:每条 = 文件名 +(可读大小);UserRole 存 dsId、+2 存文件 url。空时显示占位。
|
// 文件页签:每条 = 文件名 +(可读大小);UserRole 存 dsId、+2 存文件 url。空时显示占位。
|
||||||
void populateFileList(QStandardItemModel* model, const std::vector<geopro::data::DsRow>& rows,
|
void populateFileList(QListWidget* list, const std::vector<geopro::data::DsRow>& rows, bool append);
|
||||||
bool append);
|
|
||||||
|
|
||||||
} // namespace geopro::app
|
} // namespace geopro::app
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue