diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index 18d4bb2..9e2601a 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -403,8 +403,9 @@ void PropertyWidget::ChangHeadItemProperty() label->setPixmap(*pixmap); label->setAlignment(Qt::AlignHCenter); label->show(); + // m_formHead->m_bRefresh=false; - m_tableWidget->setCellWidget(m_iRow, m_iCol,label); + m_tableWidget->setCellWidget(m_iRow, m_iCol, label); //m_item->setIcon(QIcon(*pixmap)); // 设置背景刷 @@ -414,7 +415,17 @@ void PropertyWidget::ChangHeadItemProperty() } 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));//pixmap + label->setAlignment(Qt::AlignHCenter); + label->show(); + // + m_formHead->m_bRefresh=false; + m_tableWidget->setCellWidget(m_iRow, m_iCol, label); } } } diff --git a/logPlus/formhead.cpp b/logPlus/formhead.cpp index 7e344ab..1cc3d9d 100644 --- a/logPlus/formhead.cpp +++ b/logPlus/formhead.cpp @@ -8,12 +8,16 @@ #include #include #include +#include #include "backgrounddelegate.h" #include "PropertyWidget.h" +#include "geometryutils.h" //extern int g_iRows; //extern int g_iCols; +extern QString g_prjname; + int g_iFixedWidth=40; int g_iFixedHeight=30; @@ -156,7 +160,7 @@ void FormHead::Init(int iRows, int iCols) QSvgRenderer* svgRender = new QSvgRenderer(); svgRender->load(imagePath); // - QPixmap* pixmap = new QPixmap(colWidth, rowHeight); + QPixmap* pixmap = new QPixmap(colWidth-1, rowHeight-1); pixmap->fill(Qt::transparent);//设置背景透明 QPainter p(pixmap); svgRender->render(&p); @@ -169,7 +173,15 @@ void FormHead::Init(int iRows, int iCols) } 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(i, j,label); } } } @@ -393,16 +405,6 @@ void FormHead::copy() void FormHead::Paste() { - QString pastText = QApplication::clipboard()->text(); - QStringList rowList = pastText.split("\n", QString::KeepEmptyParts); - if(rowList.size()==0) - { - return; - } - if(rowList.at(rowList.size()-1)=="") - { - rowList.removeAt(rowList.size()-1); - } QTableWidgetItem* crtItem = ui->tableWidget->currentItem(); int rowN, colN; if (!crtItem) @@ -415,6 +417,61 @@ void FormHead::Paste() rowN = ui->tableWidget->row(crtItem); colN = ui->tableWidget->column(crtItem); } + + bool bImg=false; + QPixmap pixmap = QApplication::clipboard()->pixmap(); + if(pixmap.isNull()) + { + } + else + { + bImg=true; + + //1.直接采用控件显示 + QLabel* label = new QLabel; + label->setPixmap(pixmap); + label->setAlignment(Qt::AlignHCenter); + label->show(); + ui->tableWidget->setCellWidget(rowN, colN, label); + + // 保存为PNG文件 + QString strImg = QDateTime::currentDateTime().toString("yyyyMMdd-hhmmsszzz"); + //Logdata + QString folderPath; + folderPath = GetLogdataPath(); + folderPath = folderPath + g_prjname; + folderPath = folderPath + "/" + strImg + ".png"; + 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); + return; + } + + QString pastText = QApplication::clipboard()->text(); + QStringList rowList = pastText.split("\n", QString::KeepEmptyParts); + if(rowList.size()==0) + { + if(pixmap.isNull()) + { + return; + } + else + { + bImg=true; + } + } + + if(rowList.at(rowList.size()-1)=="") + { + rowList.removeAt(rowList.size()-1); + } + for (int i = 0; i < (ui->tableWidget->rowCount() - rowN) && (i < rowList.length()); i++) { QStringList rowDataList = rowList.at(i).split("\t", QString::KeepEmptyParts); diff --git a/logPlus/formtrack.cpp b/logPlus/formtrack.cpp index 9f291c8..92950df 100644 --- a/logPlus/formtrack.cpp +++ b/logPlus/formtrack.cpp @@ -3,6 +3,8 @@ #include #include "CallManage.h" +extern int g_iOneWidth; //道宽 + //曲线名称栏(表格) FormTrack::FormTrack(QWidget *parent, QString strWellName, QString strTrackName) : QWidget(parent), @@ -82,6 +84,10 @@ void FormTrack::s_addLine(QString strSlfName, QString strWellName, QString strTr int row = ui->tableWidget->rowCount(); ui->tableWidget->setRowCount(row + 1); + //避免出现小滚动条 + //ui->tableWidget->resize(g_iOneWidth, 100*(row + 1)+10); + //this->resize(g_iOneWidth, 100*(row + 1)+30); + //曲线信息栏 FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor); formInfo->m_strUuid = m_strUuid; diff --git a/logPlus/formwell.cpp b/logPlus/formwell.cpp index 702ddf5..9fd948d 100644 --- a/logPlus/formwell.cpp +++ b/logPlus/formwell.cpp @@ -22,6 +22,7 @@ FormWell::FormWell(QWidget *parent, QString strWellName) : //ui->tableWidget->horizontalHeader()->hide();//列 int rowcount = 3; //总行数 ui->tableWidget->setRowCount(rowcount); //动态设置行数 + //ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度 ui->tableWidget->horizontalHeader()->setFixedHeight(3); //关联信号槽 diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index 892b684..85ada73 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -86,6 +86,7 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) : //ui->tableWidget_2->horizontalHeader()->hide();//列 int rowcount = 2; //总行数 ui->tableWidget_2->setRowCount(rowcount); //动态设置行数 + //ui->tableWidget_2->verticalHeader()->setFixedWidth(3);//标题栏宽度 ui->tableWidget_2->horizontalHeader()->setFixedHeight(3);//标题栏高度 //我们让一列也可以滑动 ui->tableWidget_2->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);