|
|
|
#include "nmWxTreeWidget.h"
|
|
|
|
#include "nmData/nmDataDemo.h"
|
|
|
|
|
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <QTreeWidgetItem>
|
|
|
|
|
|
|
|
nmWxTreeWidget::nmWxTreeWidget(QWidget *parent, nmDataDemo* pAnalyzeData) : QWidget(parent), m_pAnalyzeData(pAnalyzeData)
|
|
|
|
{
|
|
|
|
this->initUI();
|
|
|
|
this->renderTree();
|
|
|
|
}
|
|
|
|
|
|
|
|
void nmWxTreeWidget::initUI()
|
|
|
|
{
|
|
|
|
// 垂直布局
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
|
|
this->setLayout(layout);
|
|
|
|
// 初始化结构树
|
|
|
|
m_treeWidget = new QTreeWidget(this);
|
|
|
|
m_treeWidget->setColumnCount(1);
|
|
|
|
m_treeWidget->setHeaderLabels(QStringList("Items"));
|
|
|
|
layout->addWidget(m_treeWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nmWxTreeWidget::renderTree()
|
|
|
|
{
|
|
|
|
if (m_treeWidget == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 如果没有数据,则清空结构树
|
|
|
|
if (m_pAnalyzeData == NULL) {
|
|
|
|
m_treeWidget->clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 创建树形视图的根节点
|
|
|
|
m_treeRoot = new QTreeWidgetItem(m_treeWidget, QStringList(m_pAnalyzeData->analyzeName()));
|
|
|
|
// 一级节点
|
|
|
|
QMap<NM_TREE_TYPE, QString> nodeMap;
|
|
|
|
nodeMap.insert(TREE_OilReservoir, tr("Oil Reservoir"));
|
|
|
|
nodeMap.insert(TREE_Data, tr("Data"));
|
|
|
|
nodeMap.insert(TREE_Mesh, tr("Mesh"));
|
|
|
|
nodeMap.insert(TREE_Solve, tr("Solve"));
|
|
|
|
nodeMap.insert(TREE_Postprocessing, tr("Postprocessing"));
|
|
|
|
for (QMap<NM_TREE_TYPE, QString>::const_iterator i = nodeMap.constBegin(); i != nodeMap.constEnd(); ++i) {
|
|
|
|
// qDebug() << i.key() << i.value();
|
|
|
|
QTreeWidgetItem* item = new QTreeWidgetItem(m_treeRoot, i.key());
|
|
|
|
item->setText(0, i.value());
|
|
|
|
if (i.key() == TREE_OilReservoir) {
|
|
|
|
QMap<NM_TREE_OIL_RESERVOIR_TYPE, QString> oilNodeMap;
|
|
|
|
oilNodeMap.insert(TREE_Oil_Reservoir_Outline, tr("Outline"));
|
|
|
|
oilNodeMap.insert(TREE_Oil_Reservoir_Well, tr("Well"));
|
|
|
|
oilNodeMap.insert(TREE_Oil_Reservoir_Fault, tr("Fault"));
|
|
|
|
oilNodeMap.insert(TREE_Oil_Reservoir_Crack, tr("Crack"));
|
|
|
|
oilNodeMap.insert(TREE_Oil_Reservoir_Region, tr("Region"));
|
|
|
|
for (QMap<NM_TREE_OIL_RESERVOIR_TYPE, QString>::const_iterator j = oilNodeMap.constBegin(); j != oilNodeMap.constEnd(); ++j) {
|
|
|
|
QTreeWidgetItem* oilItem = new QTreeWidgetItem(item, j.key());
|
|
|
|
oilItem->setText(0, j.value());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_treeRoot->setExpanded(true);
|
|
|
|
}
|