feat/vtk-3d-view #7
|
|
@ -156,40 +156,38 @@ void CategorySection::refreshArrayCombo() {
|
|||
const QSignalBlocker block(arrayCombo_);
|
||||
arrayCombo_->clear();
|
||||
arrayCombo_->addItem(QStringLiteral("全部装置"), QString());
|
||||
if (dict_) {
|
||||
const auto& en = dict_->arrayTypeEnum(); // 全局装置枚举 itemValue→中文
|
||||
// 按「加载到本段的数据自身携带的类型值」的范围筛选(用户口径)。装置/arrayType 不在 ds 行数据上
|
||||
// (实测 data/page 列表无该字段),故用 ds 已带的类型名 typeName(多为中文)作筛选维度;
|
||||
// typeName 缺失时回退 dsTypeCode + 全局枚举翻译。列出组内出现过的类型值。
|
||||
QSet<QString> seen;
|
||||
// 列出当前数据里出现过的装置值 → 中文名。兼容 ds 把装置存成 itemValue(键) 或中文名(值) 两种形态。
|
||||
for (const auto& r : rows_) {
|
||||
for (const auto& kv : r.properties) {
|
||||
const QString val = QString::fromStdString(kv.value);
|
||||
QString name;
|
||||
const auto it = en.find(kv.value);
|
||||
if (it != en.end()) {
|
||||
name = QString::fromStdString(it->second); // value 是 itemValue → 取中文名
|
||||
} else {
|
||||
for (const auto& e : en) // value 可能直接是中文名
|
||||
if (QString::fromStdString(e.second) == val) { name = val; break; }
|
||||
}
|
||||
if (name.isEmpty() || seen.contains(val)) continue;
|
||||
seen.insert(val);
|
||||
arrayCombo_->addItem(name, val); // data=实际属性值(passesFilters 据此比对)
|
||||
QString display = QString::fromStdString(r.typeName);
|
||||
QString code = display;
|
||||
if (display.isEmpty() && !r.dsTypeCode.empty()) { // 无类型名 → 用 dsTypeCode(必要时枚举翻译)
|
||||
code = QString::fromStdString(r.dsTypeCode);
|
||||
display = code;
|
||||
if (dict_) {
|
||||
const auto& en = dict_->arrayTypeEnum();
|
||||
const auto it = en.find(r.dsTypeCode);
|
||||
if (it != en.end()) display = QString::fromStdString(it->second);
|
||||
}
|
||||
}
|
||||
if (code.isEmpty() || seen.contains(code)) continue;
|
||||
seen.insert(code);
|
||||
arrayCombo_->addItem(display, code); // itemData=类型值(passesFilters 据此比对 typeName/dsTypeCode)
|
||||
}
|
||||
const int idx = arrayCombo_->findData(prev); // 尽量保留上次选择
|
||||
arrayCombo_->setCurrentIndex(idx >= 0 ? idx : 0);
|
||||
}
|
||||
|
||||
bool CategorySection::passesFilters(const DsRow& row) const {
|
||||
// 装置类型筛选(全局枚举;"全部"=空不筛):ds.properties 任一 value 命中选中 itemValue。
|
||||
// 类型筛选("全部"=空不筛):按 ds 自身类型值(typeName,回退 dsTypeCode)命中选中项。
|
||||
if (spec_.hasArrayTypeFilter && arrayCombo_) {
|
||||
const QString sel = arrayCombo_->currentData().toString();
|
||||
if (!sel.isEmpty()) {
|
||||
bool hit = false;
|
||||
for (const auto& kv : row.properties)
|
||||
if (QString::fromStdString(kv.value) == sel) { hit = true; break; }
|
||||
if (!hit) return false;
|
||||
const QString t = !row.typeName.empty() ? QString::fromStdString(row.typeName)
|
||||
: QString::fromStdString(row.dsTypeCode);
|
||||
if (t != sel) return false;
|
||||
}
|
||||
}
|
||||
// 采集时间范围(collectTime 经 dict 取;缺则回退 createTime;空范围不约束)。
|
||||
|
|
|
|||
Loading…
Reference in New Issue