添加左侧树搜索功能和双击查看数据功能
This commit is contained in:
parent
cf62a10c16
commit
59ac718dff
|
|
@ -75,8 +75,10 @@ QtProjectWidgets::QtProjectWidgets(QWidget *parent)
|
||||||
|
|
||||||
//为树 tree 创建信号槽,鼠标press时会触发对应的信号。
|
//为树 tree 创建信号槽,鼠标press时会触发对应的信号。
|
||||||
connect(ui->treeWidget, &QTreeWidget::itemPressed, this, &QtProjectWidgets::onItemClicked);
|
connect(ui->treeWidget, &QTreeWidget::itemPressed, this, &QtProjectWidgets::onItemClicked);
|
||||||
|
connect(ui->treeWidget, &QTreeWidget::itemDoubleClicked, this, &QtProjectWidgets::onItemDoubleClicked);
|
||||||
connect(ui->treeWidget, SIGNAL(closeTreeEditor()), this, SLOT(oncloseTreeEditor()));
|
connect(ui->treeWidget, SIGNAL(closeTreeEditor()), this, SLOT(oncloseTreeEditor()));
|
||||||
|
|
||||||
|
connect(ui->lineEdit, &QLineEdit::textChanged, this, &QtProjectWidgets::on_textChanged);
|
||||||
//connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &QtProjectWidgets::onItemChanged);
|
//connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &QtProjectWidgets::onItemChanged);
|
||||||
|
|
||||||
// 设置选择模式为多选模式
|
// 设置选择模式为多选模式
|
||||||
|
|
@ -829,6 +831,16 @@ void QtProjectWidgets::initWellsTreeMenu(QMenu *menu, QTreeWidget *treeWidget)
|
||||||
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onCopyObject()));
|
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onCopyObject()));
|
||||||
menu->addAction(action_New);
|
menu->addAction(action_New);
|
||||||
|
|
||||||
|
action_New = new QAction("升序", treeWidget);
|
||||||
|
action_New->setIcon(QIcon(GetImagePath() + "icon/AscendingOrder.png")); // 设置图标
|
||||||
|
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(slotAsendSort()));
|
||||||
|
menu->addAction(action_New);
|
||||||
|
|
||||||
|
action_New = new QAction("降序", treeWidget);
|
||||||
|
action_New->setIcon(QIcon(GetImagePath() + "icon/DescendingOrder.png")); // 设置图标
|
||||||
|
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(slotDesendSort()));
|
||||||
|
menu->addAction(action_New);
|
||||||
|
|
||||||
action_New = new QAction("输出数据", treeWidget);
|
action_New = new QAction("输出数据", treeWidget);
|
||||||
action_New->setIcon(QIcon(GetImagePath() + "icon/outcurves.png")); // 设置图标
|
action_New->setIcon(QIcon(GetImagePath() + "icon/outcurves.png")); // 设置图标
|
||||||
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onOutWellLogRound()));
|
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onOutWellLogRound()));
|
||||||
|
|
@ -2585,6 +2597,82 @@ void QtProjectWidgets::onCopyObject()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 左侧树搜索
|
||||||
|
void QtProjectWidgets::on_textChanged(const QString &text)
|
||||||
|
{
|
||||||
|
bool bHidden = !text.isEmpty();
|
||||||
|
QTreeWidgetItem *item = ui->treeWidget->topLevelItem(0);
|
||||||
|
int childCount = item->childCount(); // 获取子节点数量
|
||||||
|
for (int i = 0; i < childCount; ++i)
|
||||||
|
{
|
||||||
|
//井组,数据分析...
|
||||||
|
QTreeWidgetItem *wellGroupItem = item->child(i);
|
||||||
|
QString wellGroupname = wellGroupItem->text(0);
|
||||||
|
if (wellGroupname == "井组")
|
||||||
|
{
|
||||||
|
int wellCount = wellGroupItem->childCount(); // 获取井节点数量
|
||||||
|
for (int j = 0; j < wellCount; ++j)
|
||||||
|
{
|
||||||
|
//井组,数据分析...
|
||||||
|
QTreeWidgetItem *wellItem = wellGroupItem->child(j);
|
||||||
|
wellItem->setHidden(bHidden);
|
||||||
|
QString strName = wellItem->text(0);
|
||||||
|
strName = strName.toUpper();
|
||||||
|
if (!text.isEmpty() && strName.contains(text.toUpper()))
|
||||||
|
{
|
||||||
|
wellItem->setHidden(false);
|
||||||
|
ui->treeWidget->expandItem(wellGroupItem);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取井次节点数量
|
||||||
|
int wellLogCount = wellItem->childCount();
|
||||||
|
for (int k = 0; k < wellLogCount; ++k)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *wellLogItem = wellItem->child(k);
|
||||||
|
int wellLogCountChild = wellLogItem->childCount();
|
||||||
|
wellLogItem->setHidden(bHidden);
|
||||||
|
strName = wellLogItem->text(0);
|
||||||
|
strName = strName.toUpper();
|
||||||
|
if (!text.isEmpty() && strName.contains(text.toUpper()))
|
||||||
|
{
|
||||||
|
wellLogItem->setHidden(false);
|
||||||
|
ui->treeWidget->expandItem(wellItem);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int m = 0; m < wellLogCountChild; ++m)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *wellObject = wellLogItem->child(m);
|
||||||
|
wellObject->setHidden(bHidden);
|
||||||
|
int wellObjectCount = wellObject->childCount();
|
||||||
|
for (int n = 0; n < wellObjectCount; ++n)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *Object = wellObject->child(n);
|
||||||
|
Object->setHidden(bHidden);
|
||||||
|
QString strName = Object->text(0);
|
||||||
|
strName = strName.toUpper();
|
||||||
|
if (!text.isEmpty() && strName.contains(text.toUpper()))
|
||||||
|
{
|
||||||
|
item->setHidden(false);
|
||||||
|
wellGroupItem->setHidden(false);
|
||||||
|
wellItem->setHidden(false);
|
||||||
|
wellLogItem->setHidden(false);
|
||||||
|
wellObject->setHidden(false);
|
||||||
|
ui->treeWidget->expandItem(wellGroupItem);
|
||||||
|
ui->treeWidget->expandItem(wellItem);
|
||||||
|
ui->treeWidget->expandItem(wellLogItem);
|
||||||
|
ui->treeWidget->expandItem(wellObject);
|
||||||
|
Object->setHidden(false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//点击树图节点
|
//点击树图节点
|
||||||
void QtProjectWidgets::onItemClicked(QTreeWidgetItem* item, int index)
|
void QtProjectWidgets::onItemClicked(QTreeWidgetItem* item, int index)
|
||||||
{
|
{
|
||||||
|
|
@ -2688,6 +2776,33 @@ void QtProjectWidgets::onItemClicked(QTreeWidgetItem* item, int index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//双击显示
|
||||||
|
void QtProjectWidgets::onItemDoubleClicked(QTreeWidgetItem* item, int index)
|
||||||
|
{
|
||||||
|
QString strTreeTag = item->data(0, Qt::UserRole).toString();
|
||||||
|
if (strTreeTag == "curveObject"){
|
||||||
|
//曲线对象(AC、BS...)
|
||||||
|
onShowCurve(true);
|
||||||
|
}
|
||||||
|
else if (strTreeTag == "TDTObject"){
|
||||||
|
//TDT
|
||||||
|
onShowTDT(true);
|
||||||
|
}
|
||||||
|
else if (strTreeTag == "waveObject"){
|
||||||
|
//波列对象
|
||||||
|
onShowWave(true);
|
||||||
|
}
|
||||||
|
else if (strTreeTag == "cardObject"){
|
||||||
|
//参数卡对象
|
||||||
|
onShowParameterCard(true);
|
||||||
|
}
|
||||||
|
else if (strTreeTag == "tableObject")
|
||||||
|
{
|
||||||
|
//表格对象
|
||||||
|
onShowTable(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//勾选/不勾选树图节点
|
//勾选/不勾选树图节点
|
||||||
void QtProjectWidgets::onItemChanged(QTreeWidgetItem* item, int index)
|
void QtProjectWidgets::onItemChanged(QTreeWidgetItem* item, int index)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,11 @@ public slots:
|
||||||
//void s_initTreeWidget(QString strName);//初始化树图控件
|
//void s_initTreeWidget(QString strName);//初始化树图控件
|
||||||
void s_loadTreeWidget(QString fileFull);//加载树图
|
void s_loadTreeWidget(QString fileFull);//加载树图
|
||||||
|
|
||||||
|
void on_textChanged(const QString &text);
|
||||||
void onItemClicked(QTreeWidgetItem* item, int index);//鼠标点击tree菜单项
|
void onItemClicked(QTreeWidgetItem* item, int index);//鼠标点击tree菜单项
|
||||||
|
void onItemDoubleClicked(QTreeWidgetItem* item, int index);//鼠标双击tree菜单项
|
||||||
void onItemChanged(QTreeWidgetItem* item, int index);//勾选/不勾选
|
void onItemChanged(QTreeWidgetItem* item, int index);//勾选/不勾选
|
||||||
|
|
||||||
void oncloseTreeEditor(); //重命名
|
void oncloseTreeEditor(); //重命名
|
||||||
|
|
||||||
//工区管理(项目)
|
//工区管理(项目)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user