图头,支持“双击”弹窗编辑文字
This commit is contained in:
parent
eeeb3eeb72
commit
90cf020fc3
|
|
@ -2348,6 +2348,7 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
//qDebug() << "列宽(cm)->改变";
|
//qDebug() << "列宽(cm)->改变";
|
||||||
double newWidth = variant.value<double>();
|
double newWidth = variant.value<double>();
|
||||||
m_colWidth = newWidth;
|
m_colWidth = newWidth;
|
||||||
|
m_item->m_colWidth = newWidth;
|
||||||
m_formHead->m_bRefresh=false;
|
m_formHead->m_bRefresh=false;
|
||||||
//图头项改变
|
//图头项改变
|
||||||
m_tableWidget->setColumnWidth(m_iCol, m_colWidth*g_dPixelPerCm);
|
m_tableWidget->setColumnWidth(m_iCol, m_colWidth*g_dPixelPerCm);
|
||||||
|
|
@ -2359,6 +2360,7 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
//qDebug() << "行高(cm)->改变";
|
//qDebug() << "行高(cm)->改变";
|
||||||
double newHight = variant.value<double>();
|
double newHight = variant.value<double>();
|
||||||
m_rowHeight = newHight;
|
m_rowHeight = newHight;
|
||||||
|
m_item->m_rowHeight = newHight;
|
||||||
m_formHead->m_bRefresh=false;
|
m_formHead->m_bRefresh=false;
|
||||||
//图头项改变
|
//图头项改变
|
||||||
m_tableWidget->setRowHeight(m_iRow, m_rowHeight*g_dPixelPerCm);
|
m_tableWidget->setRowHeight(m_iRow, m_rowHeight*g_dPixelPerCm);
|
||||||
|
|
@ -2367,11 +2369,18 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
||||||
}
|
}
|
||||||
else if("内容" == m_propertyData[pProperty])
|
else if("内容" == m_propertyData[pProperty])
|
||||||
{
|
{
|
||||||
QString newText = variant.value<QString>();
|
if(m_strFormulaText!="")
|
||||||
//qDebug() << "内容->改变" << newText;
|
{
|
||||||
m_formHead->m_bRefresh=false;
|
QMessageBox::information(nullptr,"提示","公式状态不可修改,如需修改或删除,请到属性区修改!");
|
||||||
m_item->m_strShowTxt = newText;
|
return;
|
||||||
m_item->update();
|
}
|
||||||
|
else {
|
||||||
|
QString newText = variant.value<QString>();
|
||||||
|
//qDebug() << "内容->改变" << newText;
|
||||||
|
m_formHead->m_bRefresh=false;
|
||||||
|
m_item->m_strShowTxt = newText;
|
||||||
|
m_item->update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if("方向" == m_propertyData[pProperty])
|
else if("方向" == m_propertyData[pProperty])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -375,6 +375,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject)
|
||||||
if (value.isDouble()) {
|
if (value.isDouble()) {
|
||||||
colWidth = value.toDouble();
|
colWidth = value.toDouble();
|
||||||
//qDebug() << "colWidth:" << QString::number(colWidth);
|
//qDebug() << "colWidth:" << QString::number(colWidth);
|
||||||
|
formTableItemTmp->m_colWidth = colWidth;
|
||||||
ui->tableWidget->setColumnWidth(col, colWidth*g_dPixelPerCm);
|
ui->tableWidget->setColumnWidth(col, colWidth*g_dPixelPerCm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -385,6 +386,7 @@ void FormHead::DisplayItems(QJsonArray itemsArray, bool bMultiProject)
|
||||||
if (value.isDouble()) {
|
if (value.isDouble()) {
|
||||||
rowHeight = value.toDouble();
|
rowHeight = value.toDouble();
|
||||||
//qDebug() << "rowHeight:" << QString::number(rowHeight);
|
//qDebug() << "rowHeight:" << QString::number(rowHeight);
|
||||||
|
formTableItemTmp->m_rowHeight = rowHeight;
|
||||||
ui->tableWidget->setRowHeight(row, rowHeight*g_dPixelPerCm);
|
ui->tableWidget->setRowHeight(row, rowHeight*g_dPixelPerCm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1374,3 +1376,49 @@ void FormHead::onPasteExcelData()
|
||||||
// resizeWindow();
|
// resizeWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FormHead::getTableSize_Biggest(int &iWidth, int &iHight)
|
||||||
|
{
|
||||||
|
iWidth = 0;
|
||||||
|
iHight = 0;
|
||||||
|
|
||||||
|
int columnCount = ui->tableWidget->columnCount();//总列数
|
||||||
|
int rowCount = ui->tableWidget->rowCount();//总行数
|
||||||
|
|
||||||
|
for(int col=0; col<columnCount; col++)
|
||||||
|
{
|
||||||
|
FormTableItem* formTableItemTmp = nullptr;
|
||||||
|
auto myWidget = ui->tableWidget->cellWidget(0, col);
|
||||||
|
if(myWidget)
|
||||||
|
{
|
||||||
|
formTableItemTmp = (FormTableItem*)myWidget;//获得widget
|
||||||
|
if(!formTableItemTmp)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
iWidth += formTableItemTmp->m_colWidth * g_dPixelPerCm;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int row=0; row<rowCount; row++)
|
||||||
|
{
|
||||||
|
FormTableItem* formTableItemTmp = nullptr;
|
||||||
|
auto myWidget = ui->tableWidget->cellWidget(row, 0);
|
||||||
|
if(myWidget)
|
||||||
|
{
|
||||||
|
formTableItemTmp = (FormTableItem*)myWidget;//获得widget
|
||||||
|
if(!formTableItemTmp)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
iHight += formTableItemTmp->m_rowHeight * g_dPixelPerCm;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,9 @@ public:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
QJsonObject makeJson();
|
QJsonObject makeJson();
|
||||||
|
|
||||||
|
//获取表格的实际大小
|
||||||
|
void getTableSize_Biggest(int &iWidth, int &iHight);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void resizeWindow(bool bDelete=false);
|
void resizeWindow(bool bDelete=false);
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -389,3 +389,42 @@ void FormMultiHeads::getTableSize(int &iWidth, int &iHight)
|
||||||
iHight = iHight + 9; //Margin上方
|
iHight = iHight + 9; //Margin上方
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取表格的实际大小
|
||||||
|
void FormMultiHeads::getTableSize_Biggest(int &iWidth_Big, int &iHight_Big)
|
||||||
|
{
|
||||||
|
//获取可视视图大小 tableWidget
|
||||||
|
iHight_Big = 0;
|
||||||
|
iWidth_Big = 0;
|
||||||
|
|
||||||
|
// int iWidth_Big = 0;
|
||||||
|
// int iHight_Big = 0;
|
||||||
|
|
||||||
|
int rowCount = ui->tableWidget->rowCount();//总行数
|
||||||
|
for(int i=0; i<rowCount; i++)
|
||||||
|
{
|
||||||
|
if( ui->tableWidget->cellWidget(i, 0) != nullptr )
|
||||||
|
{
|
||||||
|
auto myWidget = ui->tableWidget->cellWidget(i, 0);
|
||||||
|
if(myWidget)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
FormHead *widgetHead = (FormHead*)myWidget;//获得widget
|
||||||
|
if(widgetHead)
|
||||||
|
{
|
||||||
|
int iWidth_Tmp = 0;
|
||||||
|
int iHight_Tmp = 0;
|
||||||
|
widgetHead->getTableSize_Biggest(iWidth_Tmp, iHight_Tmp);
|
||||||
|
if(iWidth_Tmp>iWidth_Big)
|
||||||
|
{
|
||||||
|
iWidth_Big = iWidth_Tmp;
|
||||||
|
}
|
||||||
|
if(iHight_Tmp>iHight_Big)
|
||||||
|
{
|
||||||
|
iHight_Big = iHight_Tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,8 @@ public:
|
||||||
|
|
||||||
//获取图头、结论的宽高,方便输出图
|
//获取图头、结论的宽高,方便输出图
|
||||||
void getTableSize(int &iWidth, int &iHight);
|
void getTableSize(int &iWidth, int &iHight);
|
||||||
|
//获取表格的实际大小
|
||||||
|
void getTableSize_Biggest(int &iWidth, int &iHight);
|
||||||
public:
|
public:
|
||||||
QString m_strHeadOrTail = ""; //Head代表图头, Tail代表成果表
|
QString m_strHeadOrTail = ""; //Head代表图头, Tail代表成果表
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
#include "formtableitem.h"
|
#include "formtableitem.h"
|
||||||
#include "ui_formtableitem.h"
|
#include "ui_formtableitem.h"
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
FormTableItem::FormTableItem(QWidget *parent) :
|
FormTableItem::FormTableItem(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
|
|
@ -54,15 +57,15 @@ void FormTableItem::paintEvent(QPaintEvent* event)
|
||||||
QRect rt = rect;
|
QRect rt = rect;
|
||||||
QString text = "";
|
QString text = "";
|
||||||
bool bVer = false;
|
bool bVer = false;
|
||||||
if (!m_bVerticaDrawing)
|
// if (!m_bVerticaDrawing)
|
||||||
{
|
// {
|
||||||
QFontMetrics fm1(m_txtFont);
|
// QFontMetrics fm1(m_txtFont);
|
||||||
QRect textRect = fm1.boundingRect(m_strShowTxt);
|
// QRect textRect = fm1.boundingRect(m_strShowTxt);
|
||||||
if (textRect.width() > rt.width())
|
// if (textRect.width() > rt.width())
|
||||||
{
|
// {
|
||||||
bVer = true;
|
// bVer = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (m_bVerticaDrawing || bVer)
|
if (m_bVerticaDrawing || bVer)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_strShowTxt.size(); i++) {
|
for (int i = 0; i < m_strShowTxt.size(); i++) {
|
||||||
|
|
@ -311,3 +314,28 @@ void FormTableItem::DrawBorderLines(QPainter *paint)
|
||||||
//
|
//
|
||||||
paint->restore();
|
paint->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FormTableItem::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
// 检查是否是左键双击
|
||||||
|
if (event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
if(m_strFormulaText!="")
|
||||||
|
{
|
||||||
|
QMessageBox::information(nullptr,"提示","公式状态不可修改,如需修改或删除,请到属性区修改!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ok=0;
|
||||||
|
QString Formtiom=QInputDialog::getText(NULL, "内容编辑", "内容", QLineEdit::Normal,m_strShowTxt,&ok);
|
||||||
|
if(!ok) return;
|
||||||
|
|
||||||
|
m_strShowTxt = Formtiom;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 其他按钮的双击交给基类处理
|
||||||
|
QWidget::mouseDoubleClickEvent(event);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
//
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QPixmap m_pixmap;
|
QPixmap m_pixmap;
|
||||||
|
|
|
||||||
|
|
@ -1108,7 +1108,7 @@ void MainWindowCurve::initMainToolBar()
|
||||||
|
|
||||||
connect(m_selectWellAc, &QAction::triggered, this, &MainWindowCurve::s_selectWell);
|
connect(m_selectWellAc, &QAction::triggered, this, &MainWindowCurve::s_selectWell);
|
||||||
connect(m_hvDraw, &QAction::triggered, this, &MainWindowCurve::s_hvDraw);
|
connect(m_hvDraw, &QAction::triggered, this, &MainWindowCurve::s_hvDraw);
|
||||||
connect(m_fixwellsectionHeaderAc, &QAction::triggered, this, &MainWindowCurve::s_showHeadTable);
|
connect(m_fixwellsectionHeaderAc, &QAction::triggered, this, &MainWindowCurve::s_showHeadTable_ByClick);
|
||||||
connect(m_opentemplateAc, &QAction::triggered, this, &MainWindowCurve::s_Open);
|
connect(m_opentemplateAc, &QAction::triggered, this, &MainWindowCurve::s_Open);
|
||||||
connect(m_saveastemplateAc, &QAction::triggered, this, &MainWindowCurve::s_Save);
|
connect(m_saveastemplateAc, &QAction::triggered, this, &MainWindowCurve::s_Save);
|
||||||
connect(m_openMultiProjAc, &QAction::triggered, this, &MainWindowCurve::s_OpenMultiProj);
|
connect(m_openMultiProjAc, &QAction::triggered, this, &MainWindowCurve::s_OpenMultiProj);
|
||||||
|
|
@ -4486,29 +4486,38 @@ void MainWindowCurve::_slotExport(QPrinter &printer, int IsBmp, QString pngName,
|
||||||
QRect geoRect_Tail = m_dock2->geometry();
|
QRect geoRect_Tail = m_dock2->geometry();
|
||||||
//判断头宽
|
//判断头宽
|
||||||
int iWidth_Head, iHight_Head;
|
int iWidth_Head, iHight_Head;
|
||||||
m_formMultiHeads->getTableSize(iWidth_Head, iHight_Head);
|
m_formMultiHeads->getTableSize_Biggest(iWidth_Head, iHight_Head);
|
||||||
if(iWidth_Head==0 || iHight_Head==0)
|
if(iWidth_Head==0 || iHight_Head==0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(geoRect_Head.width()>iMaxWidth)
|
if(iWidth_Head>iMaxWidth)
|
||||||
{
|
{
|
||||||
iMaxWidth = geoRect_Head.width();
|
iMaxWidth = iWidth_Head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if(geoRect_Head.width()>iMaxWidth)
|
||||||
|
// {
|
||||||
|
// iMaxWidth = geoRect_Head.width();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
//判断尾宽
|
//判断尾宽
|
||||||
int iWidth_Tail, iHight_Tail;
|
int iWidth_Tail, iHight_Tail;
|
||||||
m_formMultiTails->getTableSize(iWidth_Tail, iHight_Tail);
|
m_formMultiTails->getTableSize_Biggest(iWidth_Tail, iHight_Tail);
|
||||||
if(iWidth_Tail==0 || iHight_Tail==0)
|
if(iWidth_Tail==0 || iHight_Tail==0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(geoRect_Tail.width()>iMaxWidth)
|
if(iWidth_Tail>iMaxWidth)
|
||||||
{
|
{
|
||||||
iMaxWidth = geoRect_Tail.width();
|
iMaxWidth = iWidth_Tail;
|
||||||
}
|
}
|
||||||
|
// if(geoRect_Tail.width()>iMaxWidth)
|
||||||
|
// {
|
||||||
|
// iMaxWidth = geoRect_Tail.width();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------
|
//-----------------------------
|
||||||
|
|
@ -5200,6 +5209,17 @@ void MainWindowCurve::s_hvDraw()
|
||||||
emit CallManage::getInstance()->sig_ResizeDepth(m_strUuid, m_nObjDrawH, topDep, m_dBottomDepth);
|
emit CallManage::getInstance()->sig_ResizeDepth(m_strUuid, m_nObjDrawH, topDep, m_dBottomDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//显示/隐藏图头(手动点击工具栏)
|
||||||
|
void MainWindowCurve::s_showHeadTable_ByClick()
|
||||||
|
{
|
||||||
|
s_showHeadTable();
|
||||||
|
|
||||||
|
if(m_fixwellsectionHeaderAc->isChecked())
|
||||||
|
{
|
||||||
|
QMessageBox::information(NULL,"提示","锁头完成!",QMessageBox::Ok);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//显示/隐藏图头
|
//显示/隐藏图头
|
||||||
void MainWindowCurve::s_showHeadTable()
|
void MainWindowCurve::s_showHeadTable()
|
||||||
{
|
{
|
||||||
|
|
@ -5242,7 +5262,6 @@ void MainWindowCurve::s_showHeadTable()
|
||||||
ui->verticalScrollBar->setRange(-m_iY2*100, -m_iY1*100 - iScreenHeight + iHScrollBarHeight);
|
ui->verticalScrollBar->setRange(-m_iY2*100, -m_iY1*100 - iScreenHeight + iHScrollBarHeight);
|
||||||
ui->verticalScrollBar->setValue(-m_iY2*100);
|
ui->verticalScrollBar->setValue(-m_iY2*100);
|
||||||
|
|
||||||
QMessageBox::information(NULL,"提示","锁头完成!",QMessageBox::Ok);
|
|
||||||
//居中
|
//居中
|
||||||
emit sig_resizeWindow();
|
emit sig_resizeWindow();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,8 @@ public slots:
|
||||||
|
|
||||||
//
|
//
|
||||||
void s_selectWell(); //选择井
|
void s_selectWell(); //选择井
|
||||||
void s_hvDraw(); //横竖绘制
|
void s_hvDraw(); //横竖绘制
|
||||||
|
void s_showHeadTable_ByClick(); //显示/隐藏图头
|
||||||
void s_showHeadTable(); //显示/隐藏图头
|
void s_showHeadTable(); //显示/隐藏图头
|
||||||
void s_Open(); //加载图文件
|
void s_Open(); //加载图文件
|
||||||
void s_Save(); //保存图文件
|
void s_Save(); //保存图文件
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user