为方便拓展图头功能,切换表格item为widget
This commit is contained in:
parent
a3cb0f0394
commit
193c2f00a2
|
|
@ -2311,7 +2311,7 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
{
|
{
|
||||||
//qDebug() << "图例->改变";
|
//qDebug() << "图例->改变";
|
||||||
QString newSvg = variant.value<QString>();
|
QString newSvg = variant.value<QString>();
|
||||||
m_item->setData(Qt::UserRole+1, newSvg); // 图片路径
|
m_item->m_strImg = newSvg; // 图片路径
|
||||||
//图头项改变
|
//图头项改变
|
||||||
ChangHeadItemProperty();
|
ChangHeadItemProperty();
|
||||||
}
|
}
|
||||||
|
|
@ -2319,7 +2319,7 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
{
|
{
|
||||||
//qDebug() << "图例宽(cm)->改变";
|
//qDebug() << "图例宽(cm)->改变";
|
||||||
double newWidth = variant.value<double>();
|
double newWidth = variant.value<double>();
|
||||||
m_item->setData(Qt::UserRole+2, newWidth); // 图片路径
|
m_item->m_colWidth_Img = newWidth;
|
||||||
m_colWidth_Img = newWidth;
|
m_colWidth_Img = newWidth;
|
||||||
//图头项改变
|
//图头项改变
|
||||||
ChangHeadItemProperty();
|
ChangHeadItemProperty();
|
||||||
|
|
@ -2328,7 +2328,7 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
{
|
{
|
||||||
//qDebug() << "图例高(cm)->改变";
|
//qDebug() << "图例高(cm)->改变";
|
||||||
double newHight = variant.value<double>();
|
double newHight = variant.value<double>();
|
||||||
m_item->setData(Qt::UserRole+3, newHight); // 图片路径
|
m_item->m_rowHeight_Img = newHight;
|
||||||
m_rowHeight_Img = newHight;
|
m_rowHeight_Img = newHight;
|
||||||
//图头项改变
|
//图头项改变
|
||||||
ChangHeadItemProperty();
|
ChangHeadItemProperty();
|
||||||
|
|
@ -2340,9 +2340,8 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
// 假设variant已经被设置为包含QColor
|
// 假设variant已经被设置为包含QColor
|
||||||
QColor newColor = variant.value<QColor>();
|
QColor newColor = variant.value<QColor>();
|
||||||
// 设置字体颜色
|
// 设置字体颜色
|
||||||
QBrush brush(newColor); // 使用Qt::red预定义颜色
|
|
||||||
m_formHead->m_bRefresh=false;
|
m_formHead->m_bRefresh=false;
|
||||||
m_item->setBackground(brush);
|
m_item->m_backColor = newColor; // 使用Qt::red预定义颜色
|
||||||
}
|
}
|
||||||
else if("列宽(cm)" == m_propertyData[pProperty])
|
else if("列宽(cm)" == m_propertyData[pProperty])
|
||||||
{
|
{
|
||||||
|
|
@ -2371,7 +2370,8 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
QString newText = variant.value<QString>();
|
QString newText = variant.value<QString>();
|
||||||
//qDebug() << "内容->改变" << newText;
|
//qDebug() << "内容->改变" << newText;
|
||||||
m_formHead->m_bRefresh=false;
|
m_formHead->m_bRefresh=false;
|
||||||
m_item->setText(newText);
|
m_item->m_strShowTxt = newText;
|
||||||
|
m_item->update();
|
||||||
}
|
}
|
||||||
else if("方向" == m_propertyData[pProperty])
|
else if("方向" == m_propertyData[pProperty])
|
||||||
{
|
{
|
||||||
|
|
@ -2379,9 +2379,12 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
QString newDirection = pProperty->valueText();
|
QString newDirection = pProperty->valueText();
|
||||||
if(newDirection=="垂直")
|
if(newDirection=="垂直")
|
||||||
{
|
{
|
||||||
|
m_item->m_bVerticaDrawing = true; // 垂向绘制
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
m_item->m_bVerticaDrawing = false; // 垂向绘制
|
||||||
}
|
}
|
||||||
|
m_item->update();
|
||||||
}
|
}
|
||||||
else if("字体颜色" == m_propertyData[pProperty])
|
else if("字体颜色" == m_propertyData[pProperty])
|
||||||
{
|
{
|
||||||
|
|
@ -2390,9 +2393,9 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
// 假设variant已经被设置为包含QColor
|
// 假设variant已经被设置为包含QColor
|
||||||
QColor newColor = variant.value<QColor>();
|
QColor newColor = variant.value<QColor>();
|
||||||
// 设置字体颜色
|
// 设置字体颜色
|
||||||
QBrush brush(newColor); // 使用Qt::red预定义颜色
|
|
||||||
m_formHead->m_bRefresh=false;
|
m_formHead->m_bRefresh=false;
|
||||||
m_item->setForeground(brush);
|
m_item->m_txtColor = newColor; // 使用Qt::red预定义颜色
|
||||||
|
m_item->update();
|
||||||
}
|
}
|
||||||
else if("字体" == m_propertyData[pProperty])
|
else if("字体" == m_propertyData[pProperty])
|
||||||
{
|
{
|
||||||
|
|
@ -2402,12 +2405,13 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
QFont newFont = variant.value<QFont>();
|
QFont newFont = variant.value<QFont>();
|
||||||
// 设置字体
|
// 设置字体
|
||||||
m_formHead->m_bRefresh=false;
|
m_formHead->m_bRefresh=false;
|
||||||
m_item->setFont(newFont);
|
m_item->m_txtFont = newFont;
|
||||||
|
m_item->update();
|
||||||
}
|
}
|
||||||
else if("公式" == m_propertyData[pProperty])
|
else if("公式" == m_propertyData[pProperty])
|
||||||
{
|
{
|
||||||
QString newFormulaText = variant.value<QString>();
|
QString newFormulaText = variant.value<QString>();
|
||||||
m_item->setData(Qt::UserRole+4, newFormulaText); // 公式
|
m_item->m_strFormulaText = newFormulaText;
|
||||||
m_strFormulaText = newFormulaText;
|
m_strFormulaText = newFormulaText;
|
||||||
|
|
||||||
//slf名、井次名
|
//slf名、井次名
|
||||||
|
|
@ -2426,8 +2430,8 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_item->setData(Qt::UserRole+5, strSlfName);
|
m_item->m_strSlfName = strSlfName;
|
||||||
m_item->setData(Qt::UserRole+6, strWellName);
|
m_item->m_strWellName = strWellName;
|
||||||
|
|
||||||
//先判断公式有效性
|
//先判断公式有效性
|
||||||
QString TableName,FieldName;
|
QString TableName,FieldName;
|
||||||
|
|
@ -2456,45 +2460,25 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
}
|
}
|
||||||
//文字显示
|
//文字显示
|
||||||
m_formHead->m_bRefresh=false;
|
m_formHead->m_bRefresh=false;
|
||||||
m_item->setText(computeCellResult);
|
m_item->m_strShowTxt = computeCellResult;
|
||||||
|
m_item->update();
|
||||||
}
|
}
|
||||||
else if("公式操作类型" == m_propertyData[pProperty])
|
else if("公式操作类型" == m_propertyData[pProperty])
|
||||||
{
|
{
|
||||||
int temp = variant.value<int>();
|
int temp = variant.value<int>();
|
||||||
m_item->setData(Qt::UserRole+7, temp); // 公式操作类型
|
|
||||||
m_FormulaType = (FormualType)temp;
|
m_FormulaType = (FormualType)temp;
|
||||||
|
m_item->m_iFormulaType = temp;
|
||||||
|
|
||||||
//公式
|
//公式
|
||||||
QString strFormulaText = "";
|
QString strFormulaText = "";
|
||||||
QVariant vtFormula = m_item->data(Qt::UserRole+4);
|
strFormulaText = m_item->m_strFormulaText;
|
||||||
if (vtFormula.isValid()) {
|
|
||||||
strFormulaText = vtFormula.toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strFormulaText = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//slf名
|
//slf名
|
||||||
QString strSlfName = "";
|
QString strSlfName = "";
|
||||||
QVariant vtSlfName = m_item->data(Qt::UserRole+5);
|
strSlfName = m_item->m_strSlfName;
|
||||||
if (vtSlfName.isValid()) {
|
|
||||||
strSlfName = vtSlfName.toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strSlfName = "";
|
|
||||||
}
|
|
||||||
//井次名
|
//井次名
|
||||||
QString strWellName = "";
|
QString strWellName = "";
|
||||||
QVariant vtWellName = m_item->data(Qt::UserRole+6);
|
strWellName = m_item->m_strWellName;
|
||||||
if (vtWellName.isValid()) {
|
|
||||||
strWellName = vtWellName.toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strWellName = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//先判断公式有效性
|
//先判断公式有效性
|
||||||
QString TableName,FieldName;
|
QString TableName,FieldName;
|
||||||
|
|
@ -2523,7 +2507,8 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
}
|
}
|
||||||
//文字显示
|
//文字显示
|
||||||
m_formHead->m_bRefresh=false;
|
m_formHead->m_bRefresh=false;
|
||||||
m_item->setText(computeCellResult);
|
m_item->m_strShowTxt = computeCellResult;
|
||||||
|
m_item->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(m_strCurrentProperty == PL_OBJECT_PROPERTY) // 频率统计图
|
else if(m_strCurrentProperty == PL_OBJECT_PROPERTY) // 频率统计图
|
||||||
|
|
@ -2613,15 +2598,9 @@ void PropertyWidget::SlotPropertyChanged(QtProperty *property, const int &val, b
|
||||||
|
|
||||||
void PropertyWidget::ChangHeadItemProperty()
|
void PropertyWidget::ChangHeadItemProperty()
|
||||||
{
|
{
|
||||||
//清空
|
|
||||||
m_tableWidget->setCellWidget(m_iRow, m_iCol, nullptr);
|
|
||||||
|
|
||||||
//---------------------------
|
//---------------------------
|
||||||
QString imagePath = ""; //"./image/胜利符号库/解释结论符号/油层.svg"
|
QString imagePath = ""; //"./image/胜利符号库/解释结论符号/油层.svg"
|
||||||
QVariant bgData = m_item->data(Qt::UserRole+1); // 我们约定用这个角色存储图片路径
|
imagePath = m_item->m_strImg;
|
||||||
if (bgData.isValid()) {
|
|
||||||
imagePath = bgData.toString();
|
|
||||||
}
|
|
||||||
if(imagePath=="")
|
if(imagePath=="")
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
@ -2646,19 +2625,8 @@ void PropertyWidget::ChangHeadItemProperty()
|
||||||
QPainter p(pixmap);
|
QPainter p(pixmap);
|
||||||
svgRender->render(&p);
|
svgRender->render(&p);
|
||||||
//1.直接采用控件显示
|
//1.直接采用控件显示
|
||||||
QLabel* label = new QLabel;
|
m_item->m_pixmap = *pixmap;
|
||||||
label->setPixmap(*pixmap);
|
|
||||||
label->setAlignment(Qt::AlignHCenter);
|
|
||||||
label->show();
|
|
||||||
//
|
|
||||||
m_formHead->m_bRefresh=false;
|
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")
|
else if(strLast.toLower()==".png")
|
||||||
{
|
{
|
||||||
|
|
@ -2666,14 +2634,10 @@ void PropertyWidget::ChangHeadItemProperty()
|
||||||
QPixmap pixmap(imagePath);
|
QPixmap pixmap(imagePath);
|
||||||
//pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation);//缩放
|
//pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation);//缩放
|
||||||
//1.直接采用控件显示
|
//1.直接采用控件显示
|
||||||
QLabel* label = new QLabel;
|
m_item->m_pixmap = pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation);//图片保持比例缩放
|
||||||
label->setPixmap(pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation));//图片保持比例缩放
|
|
||||||
label->setAlignment(Qt::AlignHCenter);
|
|
||||||
label->show();
|
|
||||||
//
|
|
||||||
m_formHead->m_bRefresh=false;
|
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);
|
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)//针对模板加载,不处理属性改变,避免多次冲突
|
if(g_iLoadingJson==1)//针对模板加载,不处理属性改变,避免多次冲突
|
||||||
{
|
{
|
||||||
|
|
@ -3314,42 +3278,18 @@ void PropertyWidget::initHeadProperty(FormHead *formHead, QTableWidget *tableWid
|
||||||
listDirection.append("垂直");
|
listDirection.append("垂直");
|
||||||
|
|
||||||
QString imagePath = ""; //"./image/胜利符号库/解释结论符号/油层.svg"
|
QString imagePath = ""; //"./image/胜利符号库/解释结论符号/油层.svg"
|
||||||
QVariant bgData = m_item->data(Qt::UserRole+1); // 我们约定用这个角色存储图片路径
|
imagePath = m_item->m_strImg;
|
||||||
if (bgData.isValid()) {
|
|
||||||
imagePath = bgData.toString();
|
|
||||||
}
|
|
||||||
//图例宽
|
//图例宽
|
||||||
QVariant colWidth_Img = m_item->data(Qt::UserRole+2);
|
m_colWidth_Img = m_item->m_colWidth_Img;
|
||||||
if (colWidth_Img.isValid()) {
|
|
||||||
m_colWidth_Img = colWidth_Img.toDouble();
|
|
||||||
}
|
|
||||||
//图例高
|
//图例高
|
||||||
QVariant rowHeight_Img = m_item->data(Qt::UserRole+3);
|
m_rowHeight_Img = m_item->m_rowHeight_Img;
|
||||||
if (rowHeight_Img.isValid()) {
|
|
||||||
m_rowHeight_Img = rowHeight_Img.toDouble();
|
|
||||||
}
|
|
||||||
//行高、列宽
|
//行高、列宽
|
||||||
m_colWidth = tableWidget->columnWidth(col)/g_dPixelPerCm;
|
m_colWidth = tableWidget->columnWidth(col)/g_dPixelPerCm;
|
||||||
m_rowHeight = tableWidget->rowHeight(row)/g_dPixelPerCm;
|
m_rowHeight = tableWidget->rowHeight(row)/g_dPixelPerCm;
|
||||||
//公式
|
//公式
|
||||||
QVariant vtFormula = m_item->data(Qt::UserRole+4);
|
m_strFormulaText = m_item->m_strFormulaText;
|
||||||
if (vtFormula.isValid()) {
|
|
||||||
m_strFormulaText = vtFormula.toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_strFormulaText = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//公式操作类型
|
//公式操作类型
|
||||||
QVariant vtFormula_type = m_item->data(Qt::UserRole+7);
|
m_FormulaType = (FormualType)m_item->m_iFormulaType;
|
||||||
if (vtFormula_type.isValid()) {
|
|
||||||
m_FormulaType = (FormualType)vtFormula_type.toInt();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_FormulaType = PropertyWidget::Compute;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList enumNames;
|
QStringList enumNames;
|
||||||
enumNames << tr("计算") << tr("连接")<<tr("换行连接")<<tr("换行连接显行线")<<tr("空格连接")
|
enumNames << tr("计算") << tr("连接")<<tr("换行连接")<<tr("换行连接显行线")<<tr("空格连接")
|
||||||
|
|
@ -3360,7 +3300,7 @@ void PropertyWidget::initHeadProperty(FormHead *formHead, QTableWidget *tableWid
|
||||||
_CreateVariantPropertyItem("单元格", "图例宽(cm)", m_colWidth_Img, QVariant::Double, 0, 100);
|
_CreateVariantPropertyItem("单元格", "图例宽(cm)", m_colWidth_Img, QVariant::Double, 0, 100);
|
||||||
_CreateVariantPropertyItem("单元格", "图例高(cm)", m_rowHeight_Img, QVariant::Double, 0, 100);
|
_CreateVariantPropertyItem("单元格", "图例高(cm)", m_rowHeight_Img, QVariant::Double, 0, 100);
|
||||||
|
|
||||||
_CreateVariantPropertyItem("单元格", "背景颜色", m_item->background().color(), QVariant::Color);
|
_CreateVariantPropertyItem("单元格", "背景颜色", m_item->m_backColor, QVariant::Color);
|
||||||
|
|
||||||
if(m_strFormulaText!="")
|
if(m_strFormulaText!="")
|
||||||
{
|
{
|
||||||
|
|
@ -3369,11 +3309,18 @@ void PropertyWidget::initHeadProperty(FormHead *formHead, QTableWidget *tableWid
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_CreateVariantPropertyItem("文本", "内容", item->text(), QVariant::String);
|
_CreateVariantPropertyItem("文本", "内容", item->m_strShowTxt, QVariant::String);
|
||||||
}
|
}
|
||||||
_CreateVariantPropertyItem("文本", "字体", m_item->font(), QVariant::Font);
|
_CreateVariantPropertyItem("文本", "字体", m_item->font(), QVariant::Font);
|
||||||
//_CreateEnumPropertyItem("文本", "方向", 0, listDirection);
|
if(m_item->m_bVerticaDrawing)
|
||||||
_CreateVariantPropertyItem("文本", "字体颜色", m_item->foreground().color(), QVariant::Color);
|
{
|
||||||
|
_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_rowHeight, QVariant::Double, 0, 100);
|
||||||
_CreateVariantPropertyItem("表格", "列宽(cm)", m_colWidth, QVariant::Double, 0, 100);
|
_CreateVariantPropertyItem("表格", "列宽(cm)", m_colWidth, QVariant::Double, 0, 100);
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ public:
|
||||||
//图头
|
//图头
|
||||||
FormHead *m_formHead = nullptr;
|
FormHead *m_formHead = nullptr;
|
||||||
QTableWidget *m_tableWidget = nullptr;
|
QTableWidget *m_tableWidget = nullptr;
|
||||||
QTableWidgetItem* m_item = nullptr;
|
FormTableItem* m_item = nullptr;
|
||||||
int m_iRow;
|
int m_iRow;
|
||||||
int m_iCol;
|
int m_iCol;
|
||||||
//图头, 图例宽高
|
//图头, 图例宽高
|
||||||
|
|
@ -238,7 +238,7 @@ public:
|
||||||
//曲线
|
//曲线
|
||||||
void initCurveProperty(FormInfo *formInfo, QStringList strListOtherLine, QList<float> listMin, QList<float> listMax, QStringList strListOtherScaleType);
|
void initCurveProperty(FormInfo *formInfo, QStringList strListOtherLine, QList<float> listMin, QList<float> 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);
|
void initTableProperty(FormInfo *formInfo);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,31 +193,16 @@ void FormHead::Init(int iRows, int iCols)
|
||||||
|
|
||||||
double colWidth = g_iColsWidth;
|
double colWidth = g_iColsWidth;
|
||||||
double rowHeight = g_iRowsHight;
|
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); //图例高
|
|
||||||
|
|
||||||
// 设置背景色
|
FormTableItem* formTableItem = new FormTableItem;
|
||||||
QColor color(255, 255, 255, 255);
|
ui->tableWidget->setCellWidget(i, j, formTableItem);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化完成后再连接信号槽,防止数据初始化时激活信号
|
//初始化完成后再连接信号槽,防止数据初始化时激活信号
|
||||||
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(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)
|
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"))
|
if (itemObj.contains("text"))
|
||||||
{
|
{
|
||||||
|
|
@ -326,8 +324,8 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject)
|
||||||
QJsonValue value = itemObj.value("text");
|
QJsonValue value = itemObj.value("text");
|
||||||
if (value.isString()) {
|
if (value.isString()) {
|
||||||
QString newText = value.toString();
|
QString newText = value.toString();
|
||||||
|
formTableItemTmp->m_strShowTxt = newText;
|
||||||
//qDebug() << "text:" << newText;
|
//qDebug() << "text:" << newText;
|
||||||
item->setText(newText);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//字体
|
//字体
|
||||||
|
|
@ -336,7 +334,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject)
|
||||||
QJsonValue value = itemObj.value("Font");
|
QJsonValue value = itemObj.value("Font");
|
||||||
QFont newFont;
|
QFont newFont;
|
||||||
newFont.fromString(value.toString());
|
newFont.fromString(value.toString());
|
||||||
item->setFont(newFont);
|
formTableItemTmp->m_txtFont = newFont;
|
||||||
}
|
}
|
||||||
//字体颜色
|
//字体颜色
|
||||||
if (itemObj.contains("FontColor"))
|
if (itemObj.contains("FontColor"))
|
||||||
|
|
@ -345,8 +343,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject)
|
||||||
QColor newColor;
|
QColor newColor;
|
||||||
newColor.setNamedColor(value.toString());
|
newColor.setNamedColor(value.toString());
|
||||||
// 设置字体颜色
|
// 设置字体颜色
|
||||||
QBrush brush(newColor);
|
formTableItemTmp->m_txtColor = newColor;
|
||||||
item->setForeground(brush);
|
|
||||||
}
|
}
|
||||||
//背景颜色
|
//背景颜色
|
||||||
if (itemObj.contains("backColor"))
|
if (itemObj.contains("backColor"))
|
||||||
|
|
@ -355,8 +352,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject)
|
||||||
QColor newColor;
|
QColor newColor;
|
||||||
newColor.setNamedColor(value.toString());
|
newColor.setNamedColor(value.toString());
|
||||||
// 设置颜色
|
// 设置颜色
|
||||||
QBrush brush(newColor);
|
formTableItemTmp->m_backColor = newColor;
|
||||||
item->setBackground(brush);
|
|
||||||
}
|
}
|
||||||
//列宽(cm)
|
//列宽(cm)
|
||||||
double colWidth = 0;
|
double colWidth = 0;
|
||||||
|
|
@ -391,7 +387,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject)
|
||||||
if (value.isString()) {
|
if (value.isString()) {
|
||||||
imagePath = value.toString();
|
imagePath = value.toString();
|
||||||
//qDebug() << "imagePath:" << imagePath;
|
//qDebug() << "imagePath:" << imagePath;
|
||||||
item->setData(Qt::UserRole+1, imagePath); // 图片路径
|
formTableItemTmp->m_strImg = imagePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//图例宽(cm)
|
//图例宽(cm)
|
||||||
|
|
@ -401,7 +397,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject)
|
||||||
if (value.isDouble()) {
|
if (value.isDouble()) {
|
||||||
colWidth_Img = value.toDouble();
|
colWidth_Img = value.toDouble();
|
||||||
//qDebug() << "colWidth_Img:" << QString::number(colWidth_Img);
|
//qDebug() << "colWidth_Img:" << QString::number(colWidth_Img);
|
||||||
item->setData(Qt::UserRole+2, colWidth_Img);
|
formTableItemTmp->m_colWidth_Img = colWidth_Img;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//图例高(cm)
|
//图例高(cm)
|
||||||
|
|
@ -411,7 +407,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject)
|
||||||
if (value.isDouble()) {
|
if (value.isDouble()) {
|
||||||
rowHeight_Img = value.toDouble();
|
rowHeight_Img = value.toDouble();
|
||||||
//qDebug() << "rowHeight_Img:" << QString::number(rowHeight_Img);
|
//qDebug() << "rowHeight_Img:" << QString::number(rowHeight_Img);
|
||||||
item->setData(Qt::UserRole+3, rowHeight_Img);
|
formTableItemTmp->m_rowHeight_Img = rowHeight_Img;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(imagePath != "")
|
if(imagePath != "")
|
||||||
|
|
@ -428,7 +424,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject)
|
||||||
if (value.isString()) {
|
if (value.isString()) {
|
||||||
strFormulaText = value.toString();
|
strFormulaText = value.toString();
|
||||||
//qDebug() << "FormulaText:" << strFormulaText;
|
//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()) {
|
if (value.isString()) {
|
||||||
strSlfName = value.toString();
|
strSlfName = value.toString();
|
||||||
//qDebug() << "SlfName:" << strSlfName;
|
//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()) {
|
if (value.isString()) {
|
||||||
strWellName = value.toString();
|
strWellName = value.toString();
|
||||||
//qDebug() << "WellName:" << strWellName;
|
//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];
|
strSlfName = list[0];
|
||||||
strWellName = list[1];
|
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()) {
|
if (value.isDouble()) {
|
||||||
iFormulaType = value.toInt();
|
iFormulaType = value.toInt();
|
||||||
//qDebug() << "FormulaType:" << strWellName;
|
//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!="")
|
if(strFormulaText!="")
|
||||||
{
|
{
|
||||||
PropertyService()->m_FormulaType = (PropertyWidget::FormualType)iFormulaType;
|
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 rowSpan = 1;
|
||||||
int colSpan = 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)
|
void FormHead::ChangHeadItemProperty(int iRow, int iCol, QString imagePath, int colWidth, int rowHeight)
|
||||||
{
|
{
|
||||||
//清空
|
|
||||||
ui->tableWidget->setCellWidget(iRow, iCol, nullptr);
|
|
||||||
|
|
||||||
if(imagePath!="")
|
if(imagePath!="")
|
||||||
{
|
{
|
||||||
if(imagePath.size()>4)
|
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);
|
QString strLast = imagePath.right(4);
|
||||||
if(strLast.toLower()==".svg")
|
if(strLast.toLower()==".svg")
|
||||||
|
|
@ -578,32 +598,17 @@ void FormHead::ChangHeadItemProperty(int iRow, int iCol, QString imagePath, int
|
||||||
pixmap->fill(Qt::transparent);//设置背景透明
|
pixmap->fill(Qt::transparent);//设置背景透明
|
||||||
QPainter p(pixmap);
|
QPainter p(pixmap);
|
||||||
svgRender->render(&p);
|
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));
|
formTableItemTmp->m_pixmap = *pixmap;
|
||||||
// 设置背景刷
|
formTableItemTmp->update();
|
||||||
//QBrush brush(*pixmap);
|
|
||||||
//m_item->setBackground(brush);
|
|
||||||
//m_tableWidget->setItem(m_iRow, m_iCol, new QTableWidgetItem(QIcon(*pixmap),tr("")));
|
|
||||||
}
|
}
|
||||||
else if(strLast.toLower()==".png")
|
else if(strLast.toLower()==".png")
|
||||||
{
|
{
|
||||||
// 加载图片
|
// 加载图片
|
||||||
QPixmap pixmap(imagePath);
|
QPixmap pixmap(imagePath);
|
||||||
//pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation);//缩放
|
formTableItemTmp->m_pixmap = pixmap.scaled(colWidth-1, rowHeight-1, Qt::KeepAspectRatio, Qt::SmoothTransformation);//缩放
|
||||||
//1.直接采用控件显示
|
formTableItemTmp->update();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -627,14 +632,25 @@ QJsonObject FormHead::makeJson()
|
||||||
{
|
{
|
||||||
for(int row=0; row<rowCount; row++)
|
for(int row=0; row<rowCount; row++)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
QJsonObject formHeadObj;
|
QJsonObject formHeadObj;
|
||||||
formHeadObj["id"] = id;
|
formHeadObj["id"] = id;
|
||||||
formHeadObj["row"] = row;
|
formHeadObj["row"] = row;
|
||||||
formHeadObj["col"] = col;
|
formHeadObj["col"] = col;
|
||||||
id++;
|
id++;
|
||||||
if(item)
|
|
||||||
{
|
{
|
||||||
//图例
|
//图例
|
||||||
QString imagePath = "";
|
QString imagePath = "";
|
||||||
|
|
@ -645,63 +661,24 @@ QJsonObject FormHead::makeJson()
|
||||||
double my_colWidth = 1;
|
double my_colWidth = 1;
|
||||||
double my_rowHeight = 1;
|
double my_rowHeight = 1;
|
||||||
|
|
||||||
QVariant bgData = item->data(Qt::UserRole+1); // 我们约定用这个角色存储图片路径
|
imagePath = formTableItemTmp->m_strImg;
|
||||||
if (bgData.isValid()) {
|
my_colWidth_Img = formTableItemTmp->m_colWidth_Img;
|
||||||
imagePath = bgData.toString();
|
my_rowHeight_Img = formTableItemTmp->m_rowHeight_Img;
|
||||||
}
|
|
||||||
//图例宽
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
//公式
|
//公式
|
||||||
QString strFormulaText = "";
|
QString strFormulaText = "";
|
||||||
QVariant vtFormula = item->data(Qt::UserRole+4);
|
strFormulaText = formTableItemTmp->m_strFormulaText;
|
||||||
if (vtFormula.isValid()) {
|
|
||||||
strFormulaText = vtFormula.toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strFormulaText = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//slf名
|
//slf名
|
||||||
QString strSlfName = "";
|
QString strSlfName = "";
|
||||||
QVariant vtSlfName = item->data(Qt::UserRole+5);
|
strSlfName = formTableItemTmp->m_strSlfName;
|
||||||
if (vtSlfName.isValid()) {
|
|
||||||
strSlfName = vtSlfName.toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strSlfName = "";
|
|
||||||
}
|
|
||||||
//井次名
|
//井次名
|
||||||
QString strWellName = "";
|
QString strWellName = "";
|
||||||
QVariant vtWellName = item->data(Qt::UserRole+6);
|
strWellName = formTableItemTmp->m_strWellName;
|
||||||
if (vtWellName.isValid()) {
|
|
||||||
strWellName = vtWellName.toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strWellName = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//公式操作类型
|
//公式操作类型
|
||||||
int iFormulaType = 0;
|
int iFormulaType = 0;
|
||||||
QVariant vtFormula_type = item->data(Qt::UserRole+7);
|
iFormulaType = formTableItemTmp->m_iFormulaType;
|
||||||
if (vtFormula_type.isValid()) {
|
|
||||||
iFormulaType = vtFormula_type.toInt();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iFormulaType = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//行高、列宽
|
//行高、列宽
|
||||||
my_colWidth = ui->tableWidget->columnWidth(col)/g_dPixelPerCm;
|
my_colWidth = ui->tableWidget->columnWidth(col)/g_dPixelPerCm;
|
||||||
|
|
@ -716,17 +693,17 @@ QJsonObject FormHead::makeJson()
|
||||||
formHeadObj["imagePath"] = imagePath;
|
formHeadObj["imagePath"] = imagePath;
|
||||||
formHeadObj["colWidth_Img"] = my_colWidth_Img;
|
formHeadObj["colWidth_Img"] = my_colWidth_Img;
|
||||||
formHeadObj["rowHeight_Img"] = my_rowHeight_Img;
|
formHeadObj["rowHeight_Img"] = my_rowHeight_Img;
|
||||||
formHeadObj["backColor"] = item->background().color().name();//背景颜色
|
formHeadObj["backColor"] = formTableItemTmp->m_backColor.name();//背景颜色
|
||||||
if(strFormulaText != "")
|
if(strFormulaText != "")
|
||||||
{
|
{
|
||||||
//使用公式计算文本
|
//使用公式计算文本
|
||||||
formHeadObj["text"] = "";
|
formHeadObj["text"] = "";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
formHeadObj["text"] = item->text();
|
formHeadObj["text"] = formTableItemTmp->m_strShowTxt;
|
||||||
}
|
}
|
||||||
formHeadObj["Font"] = item->font().toString();
|
formHeadObj["Font"] = formTableItemTmp->m_txtFont.toString();
|
||||||
formHeadObj["FontColor"] = item->foreground().color().name();
|
formHeadObj["FontColor"] = formTableItemTmp->m_txtColor.name();
|
||||||
formHeadObj["colWidth"] = my_colWidth;
|
formHeadObj["colWidth"] = my_colWidth;
|
||||||
formHeadObj["rowHeight"] = my_rowHeight;
|
formHeadObj["rowHeight"] = my_rowHeight;
|
||||||
formHeadObj["rowSpan"] = rowSpan;
|
formHeadObj["rowSpan"] = rowSpan;
|
||||||
|
|
@ -735,6 +712,7 @@ QJsonObject FormHead::makeJson()
|
||||||
formHeadObj["SlfName"] = strSlfName;
|
formHeadObj["SlfName"] = strSlfName;
|
||||||
formHeadObj["WellName"] = strWellName;
|
formHeadObj["WellName"] = strWellName;
|
||||||
formHeadObj["FormulaType"] = iFormulaType;
|
formHeadObj["FormulaType"] = iFormulaType;
|
||||||
|
formHeadObj["VerticaDrawing"] = formTableItemTmp->m_bVerticaDrawing;
|
||||||
}
|
}
|
||||||
subcaseArray.append(formHeadObj);
|
subcaseArray.append(formHeadObj);
|
||||||
}
|
}
|
||||||
|
|
@ -756,38 +734,25 @@ void FormHead::s_UnSelectTableItem(QString strUuid)
|
||||||
ui->tableWidget->clearSelection();
|
ui->tableWidget->clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormHead::slotItemClicked(QTableWidgetItem* item)
|
void FormHead::slotCurrentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
|
||||||
{
|
{
|
||||||
if (item) {
|
if(currentRow>=0 && currentColumn>=0)
|
||||||
// 获取行和列索引
|
|
||||||
int row = item->row();
|
|
||||||
int column = item->column();
|
|
||||||
if(row>=0 && column>=0)
|
|
||||||
{
|
{
|
||||||
PropertyService()->initHeadProperty(this, ui->tableWidget, item, row, column);
|
auto myWidget = ui->tableWidget->cellWidget(currentRow, currentColumn);
|
||||||
|
if(myWidget)
|
||||||
|
{
|
||||||
|
FormTableItem* formTableItemTmp = (FormTableItem*)myWidget;//获得widget
|
||||||
|
if(formTableItemTmp)
|
||||||
|
{
|
||||||
|
PropertyService()->initHeadProperty(this, ui->tableWidget, formTableItemTmp, currentRow, currentColumn);
|
||||||
//取消其他表格的选中状态
|
//取消其他表格的选中状态
|
||||||
emit CallManage::getInstance()->sig_UnSelectTableItem(m_indexID);
|
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)
|
if(m_bRefresh==false)
|
||||||
{
|
{
|
||||||
|
|
@ -796,17 +761,20 @@ void FormHead::onItemChanged(QTableWidgetItem* item)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item) {
|
|
||||||
// 获取行和列索引
|
|
||||||
int row = item->row();
|
|
||||||
int column = item->column();
|
|
||||||
if(row>=0 && column>=0)
|
if(row>=0 && column>=0)
|
||||||
{
|
{
|
||||||
PropertyService()->initHeadProperty(this, ui->tableWidget, item, row, column);
|
auto myWidget = ui->tableWidget->cellWidget(row, column);
|
||||||
|
if(myWidget)
|
||||||
|
{
|
||||||
|
FormTableItem* formTableItemTmp = (FormTableItem*)myWidget;//获得widget
|
||||||
|
if(formTableItemTmp)
|
||||||
|
{
|
||||||
|
PropertyService()->initHeadProperty(this, ui->tableWidget, formTableItemTmp, row, column);
|
||||||
//取消其他表格的选中状态
|
//取消其他表格的选中状态
|
||||||
emit CallManage::getInstance()->sig_UnSelectTableItem(m_indexID);
|
emit CallManage::getInstance()->sig_UnSelectTableItem(m_indexID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormHead::slotContextMenu(QPoint pos)
|
void FormHead::slotContextMenu(QPoint pos)
|
||||||
|
|
@ -866,6 +834,12 @@ void FormHead::slotMerge()
|
||||||
int rowSpan = (bottomRow - topRow) + 1;
|
int rowSpan = (bottomRow - topRow) + 1;
|
||||||
int colSpan = (rightCol - leftCol) + 1;
|
int colSpan = (rightCol - leftCol) + 1;
|
||||||
ui->tableWidget->setSpan(topRow, leftCol, rowSpan, colSpan);
|
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, "拆分表格失败", "单元格已是最小单位,不能再进行拆分", "确定");
|
QMessageBox::warning(this, "拆分表格失败", "单元格已是最小单位,不能再进行拆分", "确定");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QList<QTableWidgetItem*> 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", "确定");
|
topRow = selectRanges[0].topRow();
|
||||||
return;
|
leftCol = selectRanges[0].leftColumn();
|
||||||
|
bottomRow = selectRanges[0].bottomRow();
|
||||||
|
rightCol = selectRanges[0].rightColumn();
|
||||||
}
|
}
|
||||||
if(selectItems.size()>1)
|
for(auto range:selectRanges)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, "拆分表格失败", "非法选择", "确定");
|
if(range.topRow()<topRow)
|
||||||
return;
|
topRow=range.topRow();
|
||||||
}
|
if(range.leftColumn()<leftCol)
|
||||||
for(auto item:selectItems)
|
leftCol=range.leftColumn();
|
||||||
{
|
if(range.bottomRow()> bottomRow)
|
||||||
row= item->row();
|
bottomRow=range.bottomRow();
|
||||||
col=item->column();
|
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();
|
int iCols = ui->tableWidget->columnCount();
|
||||||
for(int j=0; j<iCols; j++)
|
for(int j=0; j<iCols; j++)
|
||||||
{
|
{
|
||||||
QTableWidgetItem* item = new QTableWidgetItem("");
|
FormTableItem* formTableItem = new FormTableItem;
|
||||||
// 将图片路径存储在Qt::UserRole+1角色中
|
ui->tableWidget->setCellWidget(row, j, formTableItem);
|
||||||
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(row, j, item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//改变大小
|
//改变大小
|
||||||
|
|
@ -943,24 +915,8 @@ void FormHead::slotAddAfterRow()
|
||||||
int iCols = ui->tableWidget->columnCount();
|
int iCols = ui->tableWidget->columnCount();
|
||||||
for(int j=0; j<iCols; j++)
|
for(int j=0; j<iCols; j++)
|
||||||
{
|
{
|
||||||
QTableWidgetItem* item = new QTableWidgetItem("");
|
FormTableItem* formTableItem = new FormTableItem;
|
||||||
// 将图片路径存储在Qt::UserRole+1角色中
|
ui->tableWidget->setCellWidget(row+1, j, formTableItem);
|
||||||
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(row+1, j, item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//改变大小
|
//改变大小
|
||||||
|
|
@ -977,24 +933,8 @@ void FormHead::slotAddCol()
|
||||||
int iRows = ui->tableWidget->rowCount();
|
int iRows = ui->tableWidget->rowCount();
|
||||||
for(int j=0; j<iRows; j++)
|
for(int j=0; j<iRows; j++)
|
||||||
{
|
{
|
||||||
QTableWidgetItem* item = new QTableWidgetItem("");
|
FormTableItem* formTableItem = new FormTableItem;
|
||||||
// 将图片路径存储在Qt::UserRole+1角色中
|
ui->tableWidget->setCellWidget(j, col, formTableItem);
|
||||||
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(j, col, item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//改变大小
|
//改变大小
|
||||||
|
|
@ -1011,24 +951,8 @@ void FormHead::slotAddAfterCol()
|
||||||
int iRows = ui->tableWidget->rowCount();
|
int iRows = ui->tableWidget->rowCount();
|
||||||
for(int j=0; j<iRows; j++)
|
for(int j=0; j<iRows; j++)
|
||||||
{
|
{
|
||||||
QTableWidgetItem* item = new QTableWidgetItem("");
|
FormTableItem* formTableItem = new FormTableItem;
|
||||||
// 将图片路径存储在Qt::UserRole+1角色中
|
ui->tableWidget->setCellWidget(j, col+1, formTableItem);
|
||||||
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(j, col+1, item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//改变大小
|
//改变大小
|
||||||
|
|
@ -1176,11 +1100,9 @@ void FormHead::Paste()
|
||||||
bImg=true;
|
bImg=true;
|
||||||
|
|
||||||
//1.直接采用控件显示
|
//1.直接采用控件显示
|
||||||
QLabel* label = new QLabel;
|
FormTableItem* formTableItem = new FormTableItem;
|
||||||
label->setPixmap(pixmap);
|
formTableItem->m_pixmap = pixmap;
|
||||||
label->setAlignment(Qt::AlignHCenter);
|
ui->tableWidget->setCellWidget(rowN, colN, formTableItem);
|
||||||
label->show();
|
|
||||||
ui->tableWidget->setCellWidget(rowN, colN, label);
|
|
||||||
|
|
||||||
// 保存为PNG文件
|
// 保存为PNG文件
|
||||||
QString strImg = QDateTime::currentDateTime().toString("yyyyMMdd-hhmmsszzz");
|
QString strImg = QDateTime::currentDateTime().toString("yyyyMMdd-hhmmsszzz");
|
||||||
|
|
@ -1192,12 +1114,26 @@ void FormHead::Paste()
|
||||||
pixmap.save(folderPath, "PNG");
|
pixmap.save(folderPath, "PNG");
|
||||||
|
|
||||||
//
|
//
|
||||||
QTableWidgetItem* item = ui->tableWidget->item(rowN, colN);
|
FormTableItem* formTableItemTmp = nullptr;
|
||||||
// 将图片路径存储在Qt::UserRole+1角色中
|
auto myWidget = ui->tableWidget->cellWidget(rowN, colN);
|
||||||
item->setData(Qt::UserRole+1, folderPath); // 图片路径
|
if(myWidget)
|
||||||
item->setData(Qt::UserRole+2, pixmap.width()/g_dPixelPerCm); //图例宽
|
{
|
||||||
item->setData(Qt::UserRole+3, pixmap.height()/g_dPixelPerCm); //图例高
|
formTableItemTmp = (FormTableItem*)myWidget;//获得widget
|
||||||
PropertyService()->initHeadProperty(this, ui->tableWidget, item, rowN, colN);
|
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);
|
emit CallManage::getInstance()->sig_UnSelectTableItem(m_indexID);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1230,14 +1166,25 @@ void FormHead::Paste()
|
||||||
int x = i + rowN;
|
int x = i + rowN;
|
||||||
int y = j + colN;
|
int y = j + colN;
|
||||||
|
|
||||||
QTableWidgetItem* item = ui->tableWidget->item(x, y);
|
auto myWidget = ui->tableWidget->cellWidget(x, y);
|
||||||
if (item)
|
if(myWidget)
|
||||||
{
|
{
|
||||||
item->setText(rowDataList.at(j));
|
FormTableItem* formTableItemTmp = (FormTableItem*)myWidget;//获得widget
|
||||||
|
if(formTableItemTmp)
|
||||||
|
{
|
||||||
|
formTableItemTmp->m_strShowTxt = rowDataList.at(j);
|
||||||
|
formTableItemTmp->update();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->tableWidget->setItem(x, y, new QTableWidgetItem(rowDataList.at(j)));
|
FormTableItem* formTableItem = new FormTableItem;
|
||||||
|
ui->tableWidget->setCellWidget(x, y, formTableItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FormTableItem* formTableItem = new FormTableItem;
|
||||||
|
ui->tableWidget->setCellWidget(x, y, formTableItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QTableWidgetItem>
|
#include <QTableWidgetItem>
|
||||||
#include "formmultiheads.h"
|
#include "formmultiheads.h"
|
||||||
|
#include "formtableitem.h"
|
||||||
|
|
||||||
#pragma execution_character_set("utf-8")
|
#pragma execution_character_set("utf-8")
|
||||||
|
|
||||||
|
|
@ -55,9 +56,10 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void resizeWindow(bool bDelete=false);
|
void resizeWindow(bool bDelete=false);
|
||||||
//
|
//
|
||||||
void slotItemClicked(QTableWidgetItem* item);
|
//cell
|
||||||
void onItemChanged(QTableWidgetItem* item);
|
void slotCellChanged(int row, int column);
|
||||||
void onItemSelectionChanged();
|
void slotCurrentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);
|
||||||
|
|
||||||
//图头、成果表
|
//图头、成果表
|
||||||
//取消其他表格的选中状态
|
//取消其他表格的选中状态
|
||||||
void s_UnSelectTableItem(QString strUuid);
|
void s_UnSelectTableItem(QString strUuid);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include "newheaddialog.h"
|
#include "newheaddialog.h"
|
||||||
#include "formhead.h"
|
#include "formhead.h"
|
||||||
#include "qtcommonclass.h"
|
#include "qtcommonclass.h"
|
||||||
|
#include "CallManage.h"
|
||||||
|
|
||||||
extern int g_iRows;
|
extern int g_iRows;
|
||||||
extern int g_iCols;
|
extern int g_iCols;
|
||||||
|
|
@ -59,6 +60,10 @@ FormMultiHeads::FormMultiHeads(QWidget *parent) :
|
||||||
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
|
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
|
||||||
// 在窗口构造函数中
|
// 在窗口构造函数中
|
||||||
//ui->tableWidget->installEventFilter(this);
|
//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()
|
FormMultiHeads::~FormMultiHeads()
|
||||||
|
|
@ -66,6 +71,22 @@ FormMultiHeads::~FormMultiHeads()
|
||||||
delete ui;
|
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)
|
void FormMultiHeads::loadStyle(const QString &qssFile)
|
||||||
{
|
{
|
||||||
//加载样式表
|
//加载样式表
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define FORMMULTIHEADS_H
|
#define FORMMULTIHEADS_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QTableWidgetItem>
|
||||||
|
|
||||||
//
|
//
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
@ -27,7 +28,10 @@ private:
|
||||||
public slots:
|
public slots:
|
||||||
//图头右键菜单响应函数
|
//图头右键菜单响应函数
|
||||||
void slotContextMenu(QPoint pos);
|
void slotContextMenu(QPoint pos);
|
||||||
|
//鼠标点击表格
|
||||||
|
void slotCellClicked(int row, int column);
|
||||||
|
//取消其他表格的选中状态
|
||||||
|
void s_UnSelectTableItem(QString strUuid);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void loadStyle(const QString &qssFile);
|
void loadStyle(const QString &qssFile);
|
||||||
|
|
|
||||||
87
logPlus/formtableitem.cpp
Normal file
87
logPlus/formtableitem.cpp
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
#include "formtableitem.h"
|
||||||
|
#include "ui_formtableitem.h"
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
52
logPlus/formtableitem.h
Normal file
52
logPlus/formtableitem.h
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#ifndef FORMTABLEITEM_H
|
||||||
|
#define FORMTABLEITEM_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
//#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
|
||||||
21
logPlus/formtableitem.ui
Normal file
21
logPlus/formtableitem.ui
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<ui version="4.0">
|
||||||
|
<author/>
|
||||||
|
<comment/>
|
||||||
|
<exportmacro/>
|
||||||
|
<class>FormTableItem</class>
|
||||||
|
<widget name="FormTableItem" class="QWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<pixmapfunction/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
|
|
@ -73,6 +73,7 @@ SOURCES += \
|
||||||
forminfo.cpp \
|
forminfo.cpp \
|
||||||
formline.cpp \
|
formline.cpp \
|
||||||
formlogmud.cpp \
|
formlogmud.cpp \
|
||||||
|
formtableitem.cpp \
|
||||||
formwave.cpp \
|
formwave.cpp \
|
||||||
formmultiheads.cpp \
|
formmultiheads.cpp \
|
||||||
formtrack.cpp \
|
formtrack.cpp \
|
||||||
|
|
@ -149,6 +150,7 @@ HEADERS += \
|
||||||
forminfo.h \
|
forminfo.h \
|
||||||
formline.h \
|
formline.h \
|
||||||
formlogmud.h \
|
formlogmud.h \
|
||||||
|
formtableitem.h \
|
||||||
formwave.h \
|
formwave.h \
|
||||||
formmultiheads.h \
|
formmultiheads.h \
|
||||||
formtrack.h \
|
formtrack.h \
|
||||||
|
|
@ -186,6 +188,7 @@ FORMS += \
|
||||||
forminfo.ui \
|
forminfo.ui \
|
||||||
formline.ui \
|
formline.ui \
|
||||||
formlogmud.ui \
|
formlogmud.ui \
|
||||||
|
formtableitem.ui \
|
||||||
formwave.ui \
|
formwave.ui \
|
||||||
formmultiheads.ui \
|
formmultiheads.ui \
|
||||||
formtrack.ui \
|
formtrack.ui \
|
||||||
|
|
|
||||||
|
|
@ -5414,6 +5414,8 @@ void MainWindowCurve::mousePressEvent(QMouseEvent *event)
|
||||||
PropertyService()->initWidgetProperty(m_strUuid, m_iScale);
|
PropertyService()->initWidgetProperty(m_strUuid, m_iScale);
|
||||||
//取消所有选中单元格
|
//取消所有选中单元格
|
||||||
emit CallManage::getInstance()->sig_Raise(m_strUuid, "", "", "", "", 0, "");
|
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)
|
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);
|
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_Raise(m_strUuid, strSlfName, strWellName, "", "", 1, "");
|
||||||
|
//取消其他表格的选中状态(图头、成果表)
|
||||||
|
emit CallManage::getInstance()->sig_UnSelectTableItem("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowCurve::s_NewTrack()
|
void MainWindowCurve::s_NewTrack()
|
||||||
|
|
|
||||||
|
|
@ -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_Raise(m_strUuid, formInfo->m_strSlfName, formInfo->m_strWellName, formInfo->m_strTrackName, formInfo->m_strLineName, 3, formInfo->m_strType);
|
||||||
|
//取消其他表格的选中状态(图头、成果表)
|
||||||
|
emit CallManage::getInstance()->sig_UnSelectTableItem("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,8 @@ void QMyTableWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||||
PropertyService()->initTrackProperty(formTop, formTop->m_nTrackW, this, iCurrentCol);
|
PropertyService()->initTrackProperty(formTop, formTop->m_nTrackW, this, iCurrentCol);
|
||||||
//
|
//
|
||||||
emit CallManage::getInstance()->sig_Raise(strUuid, strSlfName, strWellName, strTrackName, "", 2, "");
|
emit CallManage::getInstance()->sig_Raise(strUuid, strSlfName, strWellName, strTrackName, "", 2, "");
|
||||||
|
//取消其他表格的选中状态(图头、成果表)
|
||||||
|
emit CallManage::getInstance()->sig_UnSelectTableItem("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -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_Raise(m_strUuid, m_strSlfName, m_strWellName, "", "", 1, "");
|
||||||
|
//取消其他表格的选中状态(图头、成果表)
|
||||||
|
emit CallManage::getInstance()->sig_UnSelectTableItem("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user