diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index c75410d..1d7f3c1 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -2311,7 +2311,7 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant { //qDebug() << "图例->改变"; QString newSvg = variant.value(); - m_item->setData(Qt::UserRole+1, newSvg); // 图片路径 + m_item->m_strImg = newSvg; // 图片路径 //图头项改变 ChangHeadItemProperty(); } @@ -2319,7 +2319,7 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant { //qDebug() << "图例宽(cm)->改变"; double newWidth = variant.value(); - m_item->setData(Qt::UserRole+2, newWidth); // 图片路径 + m_item->m_colWidth_Img = newWidth; m_colWidth_Img = newWidth; //图头项改变 ChangHeadItemProperty(); @@ -2328,7 +2328,7 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant { //qDebug() << "图例高(cm)->改变"; double newHight = variant.value(); - m_item->setData(Qt::UserRole+3, newHight); // 图片路径 + m_item->m_rowHeight_Img = newHight; m_rowHeight_Img = newHight; //图头项改变 ChangHeadItemProperty(); @@ -2340,9 +2340,8 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant // 假设variant已经被设置为包含QColor QColor newColor = variant.value(); // 设置字体颜色 - QBrush brush(newColor); // 使用Qt::red预定义颜色 m_formHead->m_bRefresh=false; - m_item->setBackground(brush); + m_item->m_backColor = newColor; // 使用Qt::red预定义颜色 } else if("列宽(cm)" == m_propertyData[pProperty]) { @@ -2371,7 +2370,8 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant QString newText = variant.value(); //qDebug() << "内容->改变" << newText; m_formHead->m_bRefresh=false; - m_item->setText(newText); + m_item->m_strShowTxt = newText; + m_item->update(); } else if("方向" == m_propertyData[pProperty]) { @@ -2379,9 +2379,12 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant QString newDirection = pProperty->valueText(); if(newDirection=="垂直") { + m_item->m_bVerticaDrawing = true; // 垂向绘制 } else{ + m_item->m_bVerticaDrawing = false; // 垂向绘制 } + m_item->update(); } else if("字体颜色" == m_propertyData[pProperty]) { @@ -2390,9 +2393,9 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant // 假设variant已经被设置为包含QColor QColor newColor = variant.value(); // 设置字体颜色 - QBrush brush(newColor); // 使用Qt::red预定义颜色 m_formHead->m_bRefresh=false; - m_item->setForeground(brush); + m_item->m_txtColor = newColor; // 使用Qt::red预定义颜色 + m_item->update(); } else if("字体" == m_propertyData[pProperty]) { @@ -2402,12 +2405,13 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant QFont newFont = variant.value(); // 设置字体 m_formHead->m_bRefresh=false; - m_item->setFont(newFont); + m_item->m_txtFont = newFont; + m_item->update(); } else if("公式" == m_propertyData[pProperty]) { QString newFormulaText = variant.value(); - m_item->setData(Qt::UserRole+4, newFormulaText); // 公式 + m_item->m_strFormulaText = newFormulaText; m_strFormulaText = newFormulaText; //slf名、井次名 @@ -2426,8 +2430,8 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant } } } - m_item->setData(Qt::UserRole+5, strSlfName); - m_item->setData(Qt::UserRole+6, strWellName); + m_item->m_strSlfName = strSlfName; + m_item->m_strWellName = strWellName; //先判断公式有效性 QString TableName,FieldName; @@ -2456,45 +2460,25 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant } //文字显示 m_formHead->m_bRefresh=false; - m_item->setText(computeCellResult); + m_item->m_strShowTxt = computeCellResult; + m_item->update(); } else if("公式操作类型" == m_propertyData[pProperty]) { int temp = variant.value(); - m_item->setData(Qt::UserRole+7, temp); // 公式操作类型 m_FormulaType = (FormualType)temp; + m_item->m_iFormulaType = temp; //公式 QString strFormulaText = ""; - QVariant vtFormula = m_item->data(Qt::UserRole+4); - if (vtFormula.isValid()) { - strFormulaText = vtFormula.toString(); - } - else - { - strFormulaText = ""; - } + strFormulaText = m_item->m_strFormulaText; //slf名 QString strSlfName = ""; - QVariant vtSlfName = m_item->data(Qt::UserRole+5); - if (vtSlfName.isValid()) { - strSlfName = vtSlfName.toString(); - } - else - { - strSlfName = ""; - } + strSlfName = m_item->m_strSlfName; //井次名 QString strWellName = ""; - QVariant vtWellName = m_item->data(Qt::UserRole+6); - if (vtWellName.isValid()) { - strWellName = vtWellName.toString(); - } - else - { - strWellName = ""; - } + strWellName = m_item->m_strWellName; //先判断公式有效性 QString TableName,FieldName; @@ -2523,7 +2507,8 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant } //文字显示 m_formHead->m_bRefresh=false; - m_item->setText(computeCellResult); + m_item->m_strShowTxt = computeCellResult; + m_item->update(); } } else if(m_strCurrentProperty == PL_OBJECT_PROPERTY) // 频率统计图 @@ -2613,15 +2598,9 @@ void PropertyWidget::SlotPropertyChanged(QtProperty *property, const int &val, b void PropertyWidget::ChangHeadItemProperty() { - //清空 - m_tableWidget->setCellWidget(m_iRow, m_iCol, nullptr); - //--------------------------- QString imagePath = ""; //"./image/胜利符号库/解释结论符号/油层.svg" - QVariant bgData = m_item->data(Qt::UserRole+1); // 我们约定用这个角色存储图片路径 - if (bgData.isValid()) { - imagePath = bgData.toString(); - } + imagePath = m_item->m_strImg; if(imagePath=="") { return; @@ -2646,19 +2625,8 @@ void PropertyWidget::ChangHeadItemProperty() QPainter p(pixmap); svgRender->render(&p); //1.直接采用控件显示 - QLabel* label = new QLabel; - label->setPixmap(*pixmap); - label->setAlignment(Qt::AlignHCenter); - label->show(); - // + m_item->m_pixmap = *pixmap; m_formHead->m_bRefresh=false; - m_tableWidget->setCellWidget(m_iRow, m_iCol, label); - - //m_item->setIcon(QIcon(*pixmap)); - // 设置背景刷 - //QBrush brush(*pixmap); - //m_item->setBackground(brush); - //m_tableWidget->setItem(m_iRow, m_iCol, new QTableWidgetItem(QIcon(*pixmap),tr(""))); } else if(strLast.toLower()==".png") { @@ -2666,14 +2634,10 @@ void PropertyWidget::ChangHeadItemProperty() QPixmap pixmap(imagePath); //pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation);//缩放 //1.直接采用控件显示 - QLabel* label = new QLabel; - label->setPixmap(pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation));//图片保持比例缩放 - label->setAlignment(Qt::AlignHCenter); - label->show(); - // + m_item->m_pixmap = pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation);//图片保持比例缩放 m_formHead->m_bRefresh=false; - m_tableWidget->setCellWidget(m_iRow, m_iCol, label); } + m_item->update(); } } } @@ -3290,7 +3254,7 @@ QColor intToQColor(int intColor) { return QColor(red, green, blue); } -void PropertyWidget::initHeadProperty(FormHead *formHead, QTableWidget *tableWidget, QTableWidgetItem* item, int row, int col) +void PropertyWidget::initHeadProperty(FormHead *formHead, QTableWidget *tableWidget, FormTableItem* item, int row, int col) { if(g_iLoadingJson==1)//针对模板加载,不处理属性改变,避免多次冲突 { @@ -3314,42 +3278,18 @@ void PropertyWidget::initHeadProperty(FormHead *formHead, QTableWidget *tableWid listDirection.append("垂直"); QString imagePath = ""; //"./image/胜利符号库/解释结论符号/油层.svg" - QVariant bgData = m_item->data(Qt::UserRole+1); // 我们约定用这个角色存储图片路径 - if (bgData.isValid()) { - imagePath = bgData.toString(); - } + imagePath = m_item->m_strImg; //图例宽 - QVariant colWidth_Img = m_item->data(Qt::UserRole+2); - if (colWidth_Img.isValid()) { - m_colWidth_Img = colWidth_Img.toDouble(); - } + m_colWidth_Img = m_item->m_colWidth_Img; //图例高 - QVariant rowHeight_Img = m_item->data(Qt::UserRole+3); - if (rowHeight_Img.isValid()) { - m_rowHeight_Img = rowHeight_Img.toDouble(); - } + m_rowHeight_Img = m_item->m_rowHeight_Img; //行高、列宽 m_colWidth = tableWidget->columnWidth(col)/g_dPixelPerCm; m_rowHeight = tableWidget->rowHeight(row)/g_dPixelPerCm; //公式 - QVariant vtFormula = m_item->data(Qt::UserRole+4); - if (vtFormula.isValid()) { - m_strFormulaText = vtFormula.toString(); - } - else - { - m_strFormulaText = ""; - } - + m_strFormulaText = m_item->m_strFormulaText; //公式操作类型 - QVariant vtFormula_type = m_item->data(Qt::UserRole+7); - if (vtFormula_type.isValid()) { - m_FormulaType = (FormualType)vtFormula_type.toInt(); - } - else - { - m_FormulaType = PropertyWidget::Compute; - } + m_FormulaType = (FormualType)m_item->m_iFormulaType; QStringList enumNames; enumNames << tr("计算") << tr("连接")<background().color(), QVariant::Color); + _CreateVariantPropertyItem("单元格", "背景颜色", m_item->m_backColor, QVariant::Color); if(m_strFormulaText!="") { @@ -3369,11 +3309,18 @@ void PropertyWidget::initHeadProperty(FormHead *formHead, QTableWidget *tableWid } else { - _CreateVariantPropertyItem("文本", "内容", item->text(), QVariant::String); + _CreateVariantPropertyItem("文本", "内容", item->m_strShowTxt, QVariant::String); } _CreateVariantPropertyItem("文本", "字体", m_item->font(), QVariant::Font); - //_CreateEnumPropertyItem("文本", "方向", 0, listDirection); - _CreateVariantPropertyItem("文本", "字体颜色", m_item->foreground().color(), QVariant::Color); + if(m_item->m_bVerticaDrawing) + { + _CreateEnumPropertyItem("文本", "方向", 1, listDirection); + } + else + { + _CreateEnumPropertyItem("文本", "方向", 0, listDirection); + } + _CreateVariantPropertyItem("文本", "字体颜色", m_item->m_txtColor, QVariant::Color); _CreateVariantPropertyItem("表格", "行高(cm)", m_rowHeight, QVariant::Double, 0, 100); _CreateVariantPropertyItem("表格", "列宽(cm)", m_colWidth, QVariant::Double, 0, 100); diff --git a/logPlus/PropertyWidget.h b/logPlus/PropertyWidget.h index 5ed8dfe..3128b67 100644 --- a/logPlus/PropertyWidget.h +++ b/logPlus/PropertyWidget.h @@ -160,7 +160,7 @@ public: //图头 FormHead *m_formHead = nullptr; QTableWidget *m_tableWidget = nullptr; - QTableWidgetItem* m_item = nullptr; + FormTableItem* m_item = nullptr; int m_iRow; int m_iCol; //图头, 图例宽高 @@ -238,7 +238,7 @@ public: //曲线 void initCurveProperty(FormInfo *formInfo, QStringList strListOtherLine, QList listMin, QList listMax, QStringList strListOtherScaleType); //图头 - void initHeadProperty(FormHead *formHead, QTableWidget *tableWidget, QTableWidgetItem* item, int row, int col); + void initHeadProperty(FormHead *formHead, QTableWidget *tableWidget, FormTableItem* item, int row, int col); void initTableProperty(FormInfo *formInfo); diff --git a/logPlus/formhead.cpp b/logPlus/formhead.cpp index 5790a32..0f6bf17 100644 --- a/logPlus/formhead.cpp +++ b/logPlus/formhead.cpp @@ -193,31 +193,16 @@ void FormHead::Init(int iRows, int iCols) double colWidth = g_iColsWidth; double rowHeight = g_iRowsHight; - QTableWidgetItem* item = new QTableWidgetItem("");//QString::number(i) + "-" + QString::number(j) - // 将图片路径存储在Qt::UserRole+1角色中 - item->setData(Qt::UserRole+1, ""); //图片路径 ./image/胜利符号库/解释结论符号/ - item->setData(Qt::UserRole+2, 0); //图例宽 - item->setData(Qt::UserRole+3, 0); //图例高 - // 设置背景色 - QColor color(255, 255, 255, 255); - QBrush HeadBrush = QBrush(color); - HeadBrush.setStyle(Qt::SolidPattern); - item->setBackground(HeadBrush); - item->setData(Qt::BackgroundRole, color); // 双重保险 - // 设置字体颜色 - QColor colorTxt(0, 0, 0, 255); - item->setForeground(QBrush(colorTxt)); - //item->setData(Qt::UserRole, QVariant("vertical")); - // - ui->tableWidget->setItem(i, j, item); + FormTableItem* formTableItem = new FormTableItem; + ui->tableWidget->setCellWidget(i, j, formTableItem); } } //初始化完成后再连接信号槽,防止数据初始化时激活信号 - connect(ui->tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(onItemChanged(QTableWidgetItem*))); - connect(ui->tableWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onItemSelectionChanged()));//曲线选中,置顶 connect(CallManage::getInstance(), SIGNAL(sig_UnSelectTableItem(QString)), this, SLOT(s_UnSelectTableItem(QString))); + connect(ui->tableWidget, SIGNAL(cellChanged(int, int)), this, SLOT(slotCellChanged(int, int))); + connect(ui->tableWidget, SIGNAL(currentCellChanged(int, int, int, int)), this, SLOT(slotCurrentCellChanged(int, int, int, int))); } //更新 @@ -318,7 +303,20 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) if(col>-1 && row>-1) { - QTableWidgetItem* item = ui->tableWidget->item(row, col); + FormTableItem* formTableItemTmp = nullptr; + auto myWidget = ui->tableWidget->cellWidget(row, col); + if(myWidget) + { + formTableItemTmp = (FormTableItem*)myWidget;//获得widget + if(!formTableItemTmp) + { + continue; + } + } + else{ + continue; + } + //内容 if (itemObj.contains("text")) { @@ -326,8 +324,8 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) QJsonValue value = itemObj.value("text"); if (value.isString()) { QString newText = value.toString(); + formTableItemTmp->m_strShowTxt = newText; //qDebug() << "text:" << newText; - item->setText(newText); } } //字体 @@ -336,7 +334,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) QJsonValue value = itemObj.value("Font"); QFont newFont; newFont.fromString(value.toString()); - item->setFont(newFont); + formTableItemTmp->m_txtFont = newFont; } //字体颜色 if (itemObj.contains("FontColor")) @@ -345,8 +343,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) QColor newColor; newColor.setNamedColor(value.toString()); // 设置字体颜色 - QBrush brush(newColor); - item->setForeground(brush); + formTableItemTmp->m_txtColor = newColor; } //背景颜色 if (itemObj.contains("backColor")) @@ -355,8 +352,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) QColor newColor; newColor.setNamedColor(value.toString()); // 设置颜色 - QBrush brush(newColor); - item->setBackground(brush); + formTableItemTmp->m_backColor = newColor; } //列宽(cm) double colWidth = 0; @@ -391,7 +387,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) if (value.isString()) { imagePath = value.toString(); //qDebug() << "imagePath:" << imagePath; - item->setData(Qt::UserRole+1, imagePath); // 图片路径 + formTableItemTmp->m_strImg = imagePath; } } //图例宽(cm) @@ -401,7 +397,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) if (value.isDouble()) { colWidth_Img = value.toDouble(); //qDebug() << "colWidth_Img:" << QString::number(colWidth_Img); - item->setData(Qt::UserRole+2, colWidth_Img); + formTableItemTmp->m_colWidth_Img = colWidth_Img; } } //图例高(cm) @@ -411,7 +407,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) if (value.isDouble()) { rowHeight_Img = value.toDouble(); //qDebug() << "rowHeight_Img:" << QString::number(rowHeight_Img); - item->setData(Qt::UserRole+3, rowHeight_Img); + formTableItemTmp->m_rowHeight_Img = rowHeight_Img; } } if(imagePath != "") @@ -428,7 +424,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) if (value.isString()) { strFormulaText = value.toString(); //qDebug() << "FormulaText:" << strFormulaText; - item->setData(Qt::UserRole+4, strFormulaText); + formTableItemTmp->m_strFormulaText = strFormulaText; } } @@ -444,7 +440,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) if (value.isString()) { strSlfName = value.toString(); //qDebug() << "SlfName:" << strSlfName; - item->setData(Qt::UserRole+5, strSlfName); + formTableItemTmp->m_strSlfName = strSlfName; } } @@ -455,7 +451,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) if (value.isString()) { strWellName = value.toString(); //qDebug() << "WellName:" << strWellName; - item->setData(Qt::UserRole+6, strWellName); + formTableItemTmp->m_strWellName = strWellName; } } } @@ -469,6 +465,9 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) { strSlfName = list[0]; strWellName = list[1]; + // + formTableItemTmp->m_strSlfName = strSlfName; + formTableItemTmp->m_strWellName = strWellName; } } } @@ -481,10 +480,16 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) if (value.isDouble()) { iFormulaType = value.toInt(); //qDebug() << "FormulaType:" << strWellName; - item->setData(Qt::UserRole+7, iFormulaType); + formTableItemTmp->m_iFormulaType = iFormulaType; } } + // 垂向绘制 + if (itemObj.contains("VerticaDrawing")) + { + formTableItemTmp->m_bVerticaDrawing = itemObj["VerticaDrawing"].toBool(); + } + if(strFormulaText!="") { PropertyService()->m_FormulaType = (PropertyWidget::FormualType)iFormulaType; @@ -515,9 +520,12 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) } } //文字显示 - item->setText(computeCellResult); + formTableItemTmp->m_strShowTxt = computeCellResult; } + //刷新,重新调整字体高度等 + formTableItemTmp->update(); + //合并单元格 int rowSpan = 1; int colSpan = 1; @@ -559,13 +567,25 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject) void FormHead::ChangHeadItemProperty(int iRow, int iCol, QString imagePath, int colWidth, int rowHeight) { - //清空 - ui->tableWidget->setCellWidget(iRow, iCol, nullptr); - if(imagePath!="") { if(imagePath.size()>4) { + FormTableItem* formTableItemTmp = nullptr; + auto myWidget = ui->tableWidget->cellWidget(iRow, iCol); + if(myWidget) + { + formTableItemTmp = (FormTableItem*)myWidget;//获得widget + if(!formTableItemTmp) + { + return; + } + } + else{ + return; + } + + // QString strLast = imagePath.right(4); if(strLast.toLower()==".svg") @@ -578,32 +598,17 @@ void FormHead::ChangHeadItemProperty(int iRow, int iCol, QString imagePath, int pixmap->fill(Qt::transparent);//设置背景透明 QPainter p(pixmap); svgRender->render(&p); - //1.直接采用控件显示 - QLabel* label = new QLabel; - label->setPixmap(*pixmap); - label->setAlignment(Qt::AlignHCenter); - label->show(); - // - ui->tableWidget->setCellWidget(iRow, iCol, label); - //m_item->setIcon(QIcon(*pixmap)); - // 设置背景刷 - //QBrush brush(*pixmap); - //m_item->setBackground(brush); - //m_tableWidget->setItem(m_iRow, m_iCol, new QTableWidgetItem(QIcon(*pixmap),tr(""))); + formTableItemTmp->m_pixmap = *pixmap; + formTableItemTmp->update(); + } else if(strLast.toLower()==".png") { // 加载图片 QPixmap pixmap(imagePath); - //pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation);//缩放 - //1.直接采用控件显示 - QLabel* label = new QLabel; - label->setPixmap(pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation));//图片保持比例缩放 - label->setAlignment(Qt::AlignHCenter); - label->show(); - // - ui->tableWidget->setCellWidget(iRow, iCol, label); + formTableItemTmp->m_pixmap = pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation);//缩放 + formTableItemTmp->update(); } } } @@ -627,14 +632,25 @@ QJsonObject FormHead::makeJson() { for(int row=0; rowtableWidget->item(row, col); + FormTableItem* formTableItemTmp = nullptr; + auto myWidget = ui->tableWidget->cellWidget(row, col); + if(myWidget) + { + formTableItemTmp = (FormTableItem*)myWidget;//获得widget + if(!formTableItemTmp) + { + continue; + } + } + else{ + continue; + } QJsonObject formHeadObj; formHeadObj["id"] = id; formHeadObj["row"] = row; formHeadObj["col"] = col; id++; - if(item) { //图例 QString imagePath = ""; @@ -645,63 +661,24 @@ QJsonObject FormHead::makeJson() double my_colWidth = 1; double my_rowHeight = 1; - QVariant bgData = item->data(Qt::UserRole+1); // 我们约定用这个角色存储图片路径 - if (bgData.isValid()) { - imagePath = bgData.toString(); - } - //图例宽 - QVariant colWidth_Img = item->data(Qt::UserRole+2); - if (colWidth_Img.isValid()) { - my_colWidth_Img = colWidth_Img.toDouble(); - } - //图例高 - QVariant rowHeight_Img = item->data(Qt::UserRole+3); - if (rowHeight_Img.isValid()) { - my_rowHeight_Img = rowHeight_Img.toDouble(); - } + imagePath = formTableItemTmp->m_strImg; + my_colWidth_Img = formTableItemTmp->m_colWidth_Img; + my_rowHeight_Img = formTableItemTmp->m_rowHeight_Img; //公式 QString strFormulaText = ""; - QVariant vtFormula = item->data(Qt::UserRole+4); - if (vtFormula.isValid()) { - strFormulaText = vtFormula.toString(); - } - else - { - strFormulaText = ""; - } + strFormulaText = formTableItemTmp->m_strFormulaText; //slf名 QString strSlfName = ""; - QVariant vtSlfName = item->data(Qt::UserRole+5); - if (vtSlfName.isValid()) { - strSlfName = vtSlfName.toString(); - } - else - { - strSlfName = ""; - } + strSlfName = formTableItemTmp->m_strSlfName; //井次名 QString strWellName = ""; - QVariant vtWellName = item->data(Qt::UserRole+6); - if (vtWellName.isValid()) { - strWellName = vtWellName.toString(); - } - else - { - strWellName = ""; - } + strWellName = formTableItemTmp->m_strWellName; //公式操作类型 int iFormulaType = 0; - QVariant vtFormula_type = item->data(Qt::UserRole+7); - if (vtFormula_type.isValid()) { - iFormulaType = vtFormula_type.toInt(); - } - else - { - iFormulaType = 0; - } + iFormulaType = formTableItemTmp->m_iFormulaType; //行高、列宽 my_colWidth = ui->tableWidget->columnWidth(col)/g_dPixelPerCm; @@ -716,17 +693,17 @@ QJsonObject FormHead::makeJson() formHeadObj["imagePath"] = imagePath; formHeadObj["colWidth_Img"] = my_colWidth_Img; formHeadObj["rowHeight_Img"] = my_rowHeight_Img; - formHeadObj["backColor"] = item->background().color().name();//背景颜色 + formHeadObj["backColor"] = formTableItemTmp->m_backColor.name();//背景颜色 if(strFormulaText != "") { //使用公式计算文本 formHeadObj["text"] = ""; } else{ - formHeadObj["text"] = item->text(); + formHeadObj["text"] = formTableItemTmp->m_strShowTxt; } - formHeadObj["Font"] = item->font().toString(); - formHeadObj["FontColor"] = item->foreground().color().name(); + formHeadObj["Font"] = formTableItemTmp->m_txtFont.toString(); + formHeadObj["FontColor"] = formTableItemTmp->m_txtColor.name(); formHeadObj["colWidth"] = my_colWidth; formHeadObj["rowHeight"] = my_rowHeight; formHeadObj["rowSpan"] = rowSpan; @@ -735,6 +712,7 @@ QJsonObject FormHead::makeJson() formHeadObj["SlfName"] = strSlfName; formHeadObj["WellName"] = strWellName; formHeadObj["FormulaType"] = iFormulaType; + formHeadObj["VerticaDrawing"] = formTableItemTmp->m_bVerticaDrawing; } subcaseArray.append(formHeadObj); } @@ -756,38 +734,25 @@ void FormHead::s_UnSelectTableItem(QString strUuid) ui->tableWidget->clearSelection(); } -void FormHead::slotItemClicked(QTableWidgetItem* item) +void FormHead::slotCurrentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) { - if (item) { - // 获取行和列索引 - int row = item->row(); - int column = item->column(); - if(row>=0 && column>=0) + if(currentRow>=0 && currentColumn>=0) + { + auto myWidget = ui->tableWidget->cellWidget(currentRow, currentColumn); + if(myWidget) { - PropertyService()->initHeadProperty(this, ui->tableWidget, item, row, column); - //取消其他表格的选中状态 - emit CallManage::getInstance()->sig_UnSelectTableItem(m_indexID); + FormTableItem* formTableItemTmp = (FormTableItem*)myWidget;//获得widget + if(formTableItemTmp) + { + PropertyService()->initHeadProperty(this, ui->tableWidget, formTableItemTmp, currentRow, currentColumn); + //取消其他表格的选中状态 + emit CallManage::getInstance()->sig_UnSelectTableItem(m_indexID); + } } } } -void FormHead::onItemSelectionChanged() -{ - QTableWidgetItem* item = ui->tableWidget->currentItem(); - if (item) { - // 获取行和列索引 - int row = item->row(); - int column = item->column(); - if(row>=0 && column>=0) - { - PropertyService()->initHeadProperty(this, ui->tableWidget, item, row, column); - //取消其他表格的选中状态 - emit CallManage::getInstance()->sig_UnSelectTableItem(m_indexID); - } - } -} - -void FormHead::onItemChanged(QTableWidgetItem* item) +void FormHead::slotCellChanged(int row, int column) { if(m_bRefresh==false) { @@ -796,15 +761,18 @@ void FormHead::onItemChanged(QTableWidgetItem* item) return; } - if (item) { - // 获取行和列索引 - int row = item->row(); - int column = item->column(); - if(row>=0 && column>=0) + if(row>=0 && column>=0) + { + auto myWidget = ui->tableWidget->cellWidget(row, column); + if(myWidget) { - PropertyService()->initHeadProperty(this, ui->tableWidget, item, row, column); - //取消其他表格的选中状态 - emit CallManage::getInstance()->sig_UnSelectTableItem(m_indexID); + FormTableItem* formTableItemTmp = (FormTableItem*)myWidget;//获得widget + if(formTableItemTmp) + { + PropertyService()->initHeadProperty(this, ui->tableWidget, formTableItemTmp, row, column); + //取消其他表格的选中状态 + emit CallManage::getInstance()->sig_UnSelectTableItem(m_indexID); + } } } } @@ -866,6 +834,12 @@ void FormHead::slotMerge() int rowSpan = (bottomRow - topRow) + 1; int colSpan = (rightCol - leftCol) + 1; ui->tableWidget->setSpan(topRow, leftCol, rowSpan, colSpan); + + //合并后重新刷新 + int iHight = ui->tableWidget->rowHeight(topRow); + ui->tableWidget->setRowHeight(topRow, iHight+1); + //恢复 + ui->tableWidget->setRowHeight(topRow, iHight); } @@ -879,24 +853,38 @@ void FormHead::slotSplit() QMessageBox::warning(this, "拆分表格失败", "单元格已是最小单位,不能再进行拆分", "确定"); return; } - QList selectItems = ui->tableWidget->selectedItems(); - if(selectItems.size()==0) + + int topRow = 0; + int leftCol = 0; + int bottomRow = 0; + int rightCol = 0; + + if (selectRanges.size() > 0) { - QMessageBox::warning(this, "拆分表格失败", "请先为表格设置元素item", "确定"); - return; + topRow = selectRanges[0].topRow(); + leftCol = selectRanges[0].leftColumn(); + bottomRow = selectRanges[0].bottomRow(); + rightCol = selectRanges[0].rightColumn(); } - if(selectItems.size()>1) + for(auto range:selectRanges) { - QMessageBox::warning(this, "拆分表格失败", "非法选择", "确定"); - return; - } - for(auto item:selectItems) - { - row= item->row(); - col=item->column(); + if(range.topRow() bottomRow) + bottomRow=range.bottomRow(); + if(range.rightColumn()>rightCol) + rightCol=range.rightColumn(); } - ui->tableWidget->setSpan(row, col, 1, 1); // 设置跨度为1 + ui->tableWidget->setSpan(topRow, leftCol, 1, 1); // 设置跨度为1 + + //合并后重新刷新 + int iHight = ui->tableWidget->rowHeight(topRow); + ui->tableWidget->setRowHeight(topRow, iHight+1); + //恢复 + ui->tableWidget->setRowHeight(topRow, iHight); } //前插入行 @@ -909,24 +897,8 @@ void FormHead::slotAddRow() int iCols = ui->tableWidget->columnCount(); for(int j=0; jsetData(Qt::UserRole+1, ""); //图片路径 ./image/胜利符号库/解释结论符号/ - item->setData(Qt::UserRole+2, 0); //图例宽 - item->setData(Qt::UserRole+3, 0); //图例高 - - // 设置背景色 - QColor color(255, 255, 255, 255); - QBrush HeadBrush = QBrush(color); - HeadBrush.setStyle(Qt::SolidPattern); - item->setBackground(HeadBrush); - item->setData(Qt::BackgroundRole, color); // 双重保险 - // 设置字体颜色 - QColor colorTxt(0, 0, 0, 255); - item->setForeground(QBrush(colorTxt)); - //item->setData(Qt::UserRole, QVariant("vertical")); - // - ui->tableWidget->setItem(row, j, item); + FormTableItem* formTableItem = new FormTableItem; + ui->tableWidget->setCellWidget(row, j, formTableItem); } //改变大小 @@ -943,24 +915,8 @@ void FormHead::slotAddAfterRow() int iCols = ui->tableWidget->columnCount(); for(int j=0; jsetData(Qt::UserRole+1, ""); //图片路径 ./image/胜利符号库/解释结论符号/ - item->setData(Qt::UserRole+2, 0); //图例宽 - item->setData(Qt::UserRole+3, 0); //图例高 - - // 设置背景色 - QColor color(255, 255, 255, 255); - QBrush HeadBrush = QBrush(color); - HeadBrush.setStyle(Qt::SolidPattern); - item->setBackground(HeadBrush); - item->setData(Qt::BackgroundRole, color); // 双重保险 - // 设置字体颜色 - QColor colorTxt(0, 0, 0, 255); - item->setForeground(QBrush(colorTxt)); - //item->setData(Qt::UserRole, QVariant("vertical")); - // - ui->tableWidget->setItem(row+1, j, item); + FormTableItem* formTableItem = new FormTableItem; + ui->tableWidget->setCellWidget(row+1, j, formTableItem); } //改变大小 @@ -977,24 +933,8 @@ void FormHead::slotAddCol() int iRows = ui->tableWidget->rowCount(); for(int j=0; jsetData(Qt::UserRole+1, ""); //图片路径 ./image/胜利符号库/解释结论符号/ - item->setData(Qt::UserRole+2, 0); //图例宽 - item->setData(Qt::UserRole+3, 0); //图例高 - - // 设置背景色 - QColor color(255, 255, 255, 255); - QBrush HeadBrush = QBrush(color); - HeadBrush.setStyle(Qt::SolidPattern); - item->setBackground(HeadBrush); - item->setData(Qt::BackgroundRole, color); // 双重保险 - // 设置字体颜色 - QColor colorTxt(0, 0, 0, 255); - item->setForeground(QBrush(colorTxt)); - //item->setData(Qt::UserRole, QVariant("vertical")); - // - ui->tableWidget->setItem(j, col, item); + FormTableItem* formTableItem = new FormTableItem; + ui->tableWidget->setCellWidget(j, col, formTableItem); } //改变大小 @@ -1011,24 +951,8 @@ void FormHead::slotAddAfterCol() int iRows = ui->tableWidget->rowCount(); for(int j=0; jsetData(Qt::UserRole+1, ""); //图片路径 ./image/胜利符号库/解释结论符号/ - item->setData(Qt::UserRole+2, 0); //图例宽 - item->setData(Qt::UserRole+3, 0); //图例高 - - // 设置背景色 - QColor color(255, 255, 255, 255); - QBrush HeadBrush = QBrush(color); - HeadBrush.setStyle(Qt::SolidPattern); - item->setBackground(HeadBrush); - item->setData(Qt::BackgroundRole, color); // 双重保险 - // 设置字体颜色 - QColor colorTxt(0, 0, 0, 255); - item->setForeground(QBrush(colorTxt)); - //item->setData(Qt::UserRole, QVariant("vertical")); - // - ui->tableWidget->setItem(j, col+1, item); + FormTableItem* formTableItem = new FormTableItem; + ui->tableWidget->setCellWidget(j, col+1, formTableItem); } //改变大小 @@ -1176,11 +1100,9 @@ void FormHead::Paste() bImg=true; //1.直接采用控件显示 - QLabel* label = new QLabel; - label->setPixmap(pixmap); - label->setAlignment(Qt::AlignHCenter); - label->show(); - ui->tableWidget->setCellWidget(rowN, colN, label); + FormTableItem* formTableItem = new FormTableItem; + formTableItem->m_pixmap = pixmap; + ui->tableWidget->setCellWidget(rowN, colN, formTableItem); // 保存为PNG文件 QString strImg = QDateTime::currentDateTime().toString("yyyyMMdd-hhmmsszzz"); @@ -1192,12 +1114,26 @@ void FormHead::Paste() pixmap.save(folderPath, "PNG"); // - QTableWidgetItem* item = ui->tableWidget->item(rowN, colN); - // 将图片路径存储在Qt::UserRole+1角色中 - item->setData(Qt::UserRole+1, folderPath); // 图片路径 - item->setData(Qt::UserRole+2, pixmap.width()/g_dPixelPerCm); //图例宽 - item->setData(Qt::UserRole+3, pixmap.height()/g_dPixelPerCm); //图例高 - PropertyService()->initHeadProperty(this, ui->tableWidget, item, rowN, colN); + FormTableItem* formTableItemTmp = nullptr; + auto myWidget = ui->tableWidget->cellWidget(rowN, colN); + if(myWidget) + { + formTableItemTmp = (FormTableItem*)myWidget;//获得widget + if(!formTableItemTmp) + { + return; + } + } + else{ + return; + } + + formTableItemTmp->m_strImg = folderPath; // 图片路径 + formTableItemTmp->m_colWidth_Img = pixmap.width()/g_dPixelPerCm; //图例宽 + formTableItemTmp->m_rowHeight_Img = pixmap.height()/g_dPixelPerCm; //图例高 + + // + PropertyService()->initHeadProperty(this, ui->tableWidget, formTableItemTmp, rowN, colN); //取消其他表格的选中状态 emit CallManage::getInstance()->sig_UnSelectTableItem(m_indexID); return; @@ -1230,14 +1166,25 @@ void FormHead::Paste() int x = i + rowN; int y = j + colN; - QTableWidgetItem* item = ui->tableWidget->item(x, y); - if (item) + auto myWidget = ui->tableWidget->cellWidget(x, y); + if(myWidget) { - item->setText(rowDataList.at(j)); + FormTableItem* formTableItemTmp = (FormTableItem*)myWidget;//获得widget + if(formTableItemTmp) + { + formTableItemTmp->m_strShowTxt = rowDataList.at(j); + formTableItemTmp->update(); + } + else + { + FormTableItem* formTableItem = new FormTableItem; + ui->tableWidget->setCellWidget(x, y, formTableItem); + } } else { - ui->tableWidget->setItem(x, y, new QTableWidgetItem(rowDataList.at(j))); + FormTableItem* formTableItem = new FormTableItem; + ui->tableWidget->setCellWidget(x, y, formTableItem); } } } diff --git a/logPlus/formhead.h b/logPlus/formhead.h index 8795f78..261734a 100644 --- a/logPlus/formhead.h +++ b/logPlus/formhead.h @@ -4,6 +4,7 @@ #include #include #include "formmultiheads.h" +#include "formtableitem.h" #pragma execution_character_set("utf-8") @@ -55,9 +56,10 @@ public: public slots: void resizeWindow(bool bDelete=false); // - void slotItemClicked(QTableWidgetItem* item); - void onItemChanged(QTableWidgetItem* item); - void onItemSelectionChanged(); + //cell + void slotCellChanged(int row, int column); + void slotCurrentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn); + //图头、成果表 //取消其他表格的选中状态 void s_UnSelectTableItem(QString strUuid); diff --git a/logPlus/formmultiheads.cpp b/logPlus/formmultiheads.cpp index 9e4d456..fd55ed7 100644 --- a/logPlus/formmultiheads.cpp +++ b/logPlus/formmultiheads.cpp @@ -8,6 +8,7 @@ #include "newheaddialog.h" #include "formhead.h" #include "qtcommonclass.h" +#include "CallManage.h" extern int g_iRows; extern int g_iCols; @@ -59,6 +60,10 @@ FormMultiHeads::FormMultiHeads(QWidget *parent) : connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint))); // 在窗口构造函数中 //ui->tableWidget->installEventFilter(this); + //鼠标点击表格 + connect(ui->tableWidget, SIGNAL(cellClicked(int, int)), this, SLOT(slotCellClicked(int, int))); + //取消选中 + connect(CallManage::getInstance(), SIGNAL(sig_UnSelectTableItem(QString)), this, SLOT(s_UnSelectTableItem(QString))); } FormMultiHeads::~FormMultiHeads() @@ -66,6 +71,22 @@ FormMultiHeads::~FormMultiHeads() delete ui; } +void FormMultiHeads::slotCellClicked(int row, int column) +{ + qDebug() << "FormMultiHeads slotCellClicked"; + + //取消其他表格的选中状态(图头、成果表) + emit CallManage::getInstance()->sig_UnSelectTableItem(""); +} + +//图头、成果表 +//取消其他表格的选中状态 +void FormMultiHeads::s_UnSelectTableItem(QString strUuid) +{ + //取消表格的选中状态 + ui->tableWidget->clearSelection(); +} + void FormMultiHeads::loadStyle(const QString &qssFile) { //加载样式表 diff --git a/logPlus/formmultiheads.h b/logPlus/formmultiheads.h index 4a05175..f21a3b5 100644 --- a/logPlus/formmultiheads.h +++ b/logPlus/formmultiheads.h @@ -2,6 +2,7 @@ #define FORMMULTIHEADS_H #include +#include // #include @@ -27,7 +28,10 @@ private: public slots: //图头右键菜单响应函数 void slotContextMenu(QPoint pos); - + //鼠标点击表格 + void slotCellClicked(int row, int column); + //取消其他表格的选中状态 + void s_UnSelectTableItem(QString strUuid); public: void loadStyle(const QString &qssFile); diff --git a/logPlus/formtableitem.cpp b/logPlus/formtableitem.cpp new file mode 100644 index 0000000..7eb0686 --- /dev/null +++ b/logPlus/formtableitem.cpp @@ -0,0 +1,87 @@ +#include "formtableitem.h" +#include "ui_formtableitem.h" +#include + +FormTableItem::FormTableItem(QWidget *parent) : + QWidget(parent), + ui(new Ui::FormTableItem) +{ + ui->setupUi(this); +} + +FormTableItem::~FormTableItem() +{ + delete ui; +} + +void FormTableItem::paintEvent(QPaintEvent* event) +{ + QPainter painter(this); + QRect rect = this->rect(); + + // 获取RGB值 + int red = m_backColor.red(); + int green = m_backColor.green(); + int blue = m_backColor.blue(); + if(red==255 && green==255 && blue==255) + { + //背景(透明) + painter.fillRect(rect.left(), rect.top(), rect.width(), rect.height(), QColor(255, 255, 255, 0)); + } + else + { + //背景 + painter.fillRect(rect.left(), rect.top(), rect.width(), rect.height(), m_backColor); + } + + if(!m_pixmap.isNull()) + { + painter.drawPixmap(0, 0, m_pixmap); + } + +// //测试画框 +// painter.setPen(Qt::red); +// QRect rectRound(rect.left(), rect.top(), rect.width(), rect.height()); +// painter.drawRect(rectRound); + + // + painter.setBrush(Qt::NoBrush); // 确保文字不被填充色遮挡 + painter.setFont(m_txtFont); + painter.setPen(m_txtColor); + + if (m_strShowTxt.length()>0) + { + QRect rt = rect; + QString text = ""; + bool bVer = false; + if (!m_bVerticaDrawing) + { + QFontMetrics fm1(m_txtFont); + QRect textRect = fm1.boundingRect(m_strShowTxt); + if (textRect.width() > rt.width()) + { + bVer = true; + } + } + if (m_bVerticaDrawing || bVer) + { + for (int i = 0; i < m_strShowTxt.size(); i++) { + if (!i)text += m_strShowTxt.at(i); + else { + text += "\n"; + text += m_strShowTxt.at(i); + } + } + } + else + { +// rt.setX(rect.left()); +// rt.setY(rect.top() + rect.height() / 3); +// rt.setWidth(rect.width()); +// rt.setHeight(rect.height() / 3); + text = m_strShowTxt; + } + //文字 + painter.drawText(rt, Qt::AlignCenter, text); + } +} diff --git a/logPlus/formtableitem.h b/logPlus/formtableitem.h new file mode 100644 index 0000000..577af6b --- /dev/null +++ b/logPlus/formtableitem.h @@ -0,0 +1,52 @@ +#ifndef FORMTABLEITEM_H +#define FORMTABLEITEM_H + +#include +//#include "PropertyWidget.h" + +#pragma execution_character_set("utf-8") + +namespace Ui { +class FormTableItem; +} + +class FormTableItem : public QWidget +{ + Q_OBJECT + +public: + explicit FormTableItem(QWidget *parent = nullptr); + ~FormTableItem(); + +private: + Ui::FormTableItem *ui; + +protected: + void paintEvent(QPaintEvent *event); + +public: + QPixmap m_pixmap; + QFont m_txtFont; // 字体 + QColor m_txtColor; //文字颜色 + QColor m_backColor = QColor(255, 255, 255, 255); //背景颜色 + bool m_bVerticaDrawing = false; // 垂向绘制 + QString m_strShowTxt = ""; + QString m_strImg = ""; + //图头, 图例宽高 + double m_colWidth_Img = 1; + double m_rowHeight_Img = 1; + + //公式 + QString m_strFormulaText = ""; + // 公式操作符类型 + int m_iFormulaType = 0; + + //图头, 行高、列宽 + double m_colWidth = 1; + double m_rowHeight = 1; + + QString m_strSlfName = ""; + QString m_strWellName = ""; +}; + +#endif // FORMTABLEITEM_H diff --git a/logPlus/formtableitem.ui b/logPlus/formtableitem.ui new file mode 100644 index 0000000..3d416f0 --- /dev/null +++ b/logPlus/formtableitem.ui @@ -0,0 +1,21 @@ + + + + + FormTableItem + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/logPlus/logPlus.pro b/logPlus/logPlus.pro index a208334..bff1eee 100644 --- a/logPlus/logPlus.pro +++ b/logPlus/logPlus.pro @@ -73,6 +73,7 @@ SOURCES += \ forminfo.cpp \ formline.cpp \ formlogmud.cpp \ + formtableitem.cpp \ formwave.cpp \ formmultiheads.cpp \ formtrack.cpp \ @@ -149,6 +150,7 @@ HEADERS += \ forminfo.h \ formline.h \ formlogmud.h \ + formtableitem.h \ formwave.h \ formmultiheads.h \ formtrack.h \ @@ -186,6 +188,7 @@ FORMS += \ forminfo.ui \ formline.ui \ formlogmud.ui \ + formtableitem.ui \ formwave.ui \ formmultiheads.ui \ formtrack.ui \ diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index e30962b..e7d68e0 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -5414,6 +5414,8 @@ void MainWindowCurve::mousePressEvent(QMouseEvent *event) PropertyService()->initWidgetProperty(m_strUuid, m_iScale); //取消所有选中单元格 emit CallManage::getInstance()->sig_Raise(m_strUuid, "", "", "", "", 0, ""); + //取消其他表格的选中状态(图头、成果表) + emit CallManage::getInstance()->sig_UnSelectTableItem(""); } void MainWindowCurve::s_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int iTableType, QString strFormInfoType) @@ -5464,7 +5466,8 @@ void MainWindowCurve::onItemClicked(QTableWidgetItem* item) PropertyService()->initWellProperty(m_strUuid, strSlfName, strWellName, m_iY1, m_iY2, fWell); //取消所有选中单元格 emit CallManage::getInstance()->sig_Raise(m_strUuid, strSlfName, strWellName, "", "", 1, ""); - + //取消其他表格的选中状态(图头、成果表) + emit CallManage::getInstance()->sig_UnSelectTableItem(""); } void MainWindowCurve::s_NewTrack() diff --git a/logPlus/preqtablewidget.cpp b/logPlus/preqtablewidget.cpp index 4fc8bef..aba3d38 100644 --- a/logPlus/preqtablewidget.cpp +++ b/logPlus/preqtablewidget.cpp @@ -733,6 +733,8 @@ void PreQTableWidget::mouseReleaseEvent(QMouseEvent *event) //曲线置顶显示,激活可选 emit CallManage::getInstance()->sig_Raise(m_strUuid, formInfo->m_strSlfName, formInfo->m_strWellName, formInfo->m_strTrackName, formInfo->m_strLineName, 3, formInfo->m_strType); + //取消其他表格的选中状态(图头、成果表) + emit CallManage::getInstance()->sig_UnSelectTableItem(""); } } } diff --git a/logPlus/qmytablewidget.cpp b/logPlus/qmytablewidget.cpp index 3e9ebbc..5fc165e 100644 --- a/logPlus/qmytablewidget.cpp +++ b/logPlus/qmytablewidget.cpp @@ -157,6 +157,8 @@ void QMyTableWidget::mouseReleaseEvent(QMouseEvent *event) PropertyService()->initTrackProperty(formTop, formTop->m_nTrackW, this, iCurrentCol); // emit CallManage::getInstance()->sig_Raise(strUuid, strSlfName, strWellName, strTrackName, "", 2, ""); + //取消其他表格的选中状态(图头、成果表) + emit CallManage::getInstance()->sig_UnSelectTableItem(""); } } else { diff --git a/logPlus/wellheader.cpp b/logPlus/wellheader.cpp index 2ec1098..9518bbb 100644 --- a/logPlus/wellheader.cpp +++ b/logPlus/wellheader.cpp @@ -65,6 +65,8 @@ void WellHeader::mouseReleaseEvent(QMouseEvent *event) //选中单元格 emit CallManage::getInstance()->sig_Raise(m_strUuid, m_strSlfName, m_strWellName, "", "", 1, ""); - } + //取消其他表格的选中状态(图头、成果表) + emit CallManage::getInstance()->sig_UnSelectTableItem(""); + } }