706 lines
20 KiB
C++
706 lines
20 KiB
C++
#include "assetcopy.h"
|
|
#include <QMenu>
|
|
#include <QApplication>
|
|
#include <QMimeData>
|
|
#include <QClipboard>
|
|
#include <qtablewidget.h>
|
|
#include "ObjWelllogTABLE.h"
|
|
// #include "ObjDiscreteWellLog.h"
|
|
// #include "BaseDialog.h"
|
|
#include "DepthProgress.h"
|
|
#define DECIMALPLACESNUM 8
|
|
|
|
//定义表格的行高
|
|
#define DefRowHeight 20
|
|
//列宽
|
|
#define DefColWidth 180
|
|
|
|
AssetCopy* AssetCopy::p_assCopy =NULL;
|
|
|
|
AssetCopy::AssetCopy(QObject *parent)
|
|
: QObject(parent),m_menu(NULL)
|
|
{
|
|
m_isParse=false;
|
|
}
|
|
|
|
AssetCopy::~AssetCopy()
|
|
{
|
|
if(NULL != m_menu)
|
|
{
|
|
m_menu=NULL;
|
|
}
|
|
if(NULL !=p_assCopy)
|
|
{
|
|
p_assCopy=NULL;
|
|
}
|
|
}
|
|
void AssetCopy::SetWellLogs(DType type1,QList<CObjWellLog*>&pWellLogs)
|
|
{
|
|
type=type1;
|
|
m_pWellLogs=pWellLogs;
|
|
}
|
|
void AssetCopy::onCustomContextMenuRequested(const QPoint &pos)
|
|
{
|
|
if(NULL != m_menu)
|
|
{
|
|
m_menu->exec(pos);
|
|
}
|
|
}
|
|
|
|
void AssetCopy::onCopyData()
|
|
{
|
|
m_isParse=false;
|
|
if(NULL == m_menu || NULL == m_menu->parent())
|
|
return;
|
|
|
|
QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
|
|
if(NULL == m_table)
|
|
return;
|
|
//if(m_table->isVisible())
|
|
|
|
QList<QTableWidgetItem*> selItems=m_table->selectedItems();
|
|
QList<QTableWidgetSelectionRange> selRanges=m_table->selectedRanges();
|
|
if(selItems.size()>0)
|
|
{
|
|
QTableWidgetSelectionRange copyRange=selRanges.value(0);
|
|
|
|
int top = copyRange.topRow();
|
|
int bottom = copyRange.bottomRow();
|
|
int left = copyRange.leftColumn();
|
|
int right = copyRange.rightColumn();
|
|
|
|
QString szClipText;
|
|
for(int nRow = top;nRow <=bottom;nRow++)
|
|
{
|
|
for(int nCol = left;nCol <=right;nCol++)
|
|
{
|
|
QString szTmp;
|
|
auto pItem = m_table->item(nRow,nCol);
|
|
if(pItem)
|
|
szTmp = pItem->text();
|
|
szClipText.append(szTmp);
|
|
szClipText.append("\t");
|
|
}
|
|
szClipText.chop(1);
|
|
szClipText.append("\n");
|
|
}
|
|
|
|
QClipboard* clip=QApplication::clipboard();
|
|
clip->setText(szClipText);
|
|
|
|
}
|
|
}
|
|
void AssetCopy::onCopyLinesData()
|
|
{
|
|
if(!m_pWellLogs.size()) return;
|
|
m_isParse=false;
|
|
if(NULL == m_menu || NULL == m_menu->parent()) return;
|
|
QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
|
|
if(NULL == m_table)
|
|
return;
|
|
//if(m_table->isVisible())
|
|
|
|
QList<QTableWidgetItem*> selItems=m_table->selectedItems();
|
|
QList<QTableWidgetSelectionRange> selRanges=m_table->selectedRanges();
|
|
|
|
// CObjWellLogWavefile *pWaveValue=NULL;
|
|
// pWaveValue=dynamic_cast<CObjWellLogWavefile *>(m_pWellLogs[0]);
|
|
CObjWellLogTABLE *pTableValue=NULL;
|
|
pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
|
|
if(selItems.size()>0)
|
|
{
|
|
QTableWidgetSelectionRange copyRange=selRanges.value(0);
|
|
|
|
int top = m_verScrolValue+copyRange.topRow();
|
|
int bottom = m_verScrolValue+copyRange.bottomRow();
|
|
int left = 0;//copyRange.leftColumn();
|
|
int right = m_horScrolValue+m_table->columnCount();
|
|
|
|
/* if(pWaveValue) right =pWaveValue->waveinfo.TimeSamples;
|
|
else */if(!pTableValue) right=m_pWellLogs.size();
|
|
char buffer[200];
|
|
QString szClipText;
|
|
float stdep=999999;
|
|
for(int i = 0; i < m_pWellLogs.size(); i++) {
|
|
if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep)
|
|
stdep = m_pWellLogs[i]->acurveinfo.StartDepth;
|
|
}
|
|
double dep=0;
|
|
int nCurrentRow = m_table->currentRow();
|
|
|
|
for(int nRow = top;nRow <= bottom; nRow++)
|
|
{
|
|
if(!pTableValue)
|
|
dep=stdep+nRow*m_pWellLogs[0]->acurveinfo.DepLevel;
|
|
|
|
for(int nCol = left;nCol < right; nCol++)
|
|
{
|
|
QString szTmp;
|
|
if(nCol==0||pTableValue) {
|
|
auto pItem = m_table->item(nRow,nCol);
|
|
if(pItem)
|
|
szTmp = pItem->text();
|
|
else
|
|
szTmp=toString(dep,'f',5,0);
|
|
}
|
|
else {
|
|
/* if(pWaveValue) szTmp=toString(pWaveValue->GetData((float)dep,nCol-1,buffer),'f',DECIMALPLACESNUM,0);
|
|
else */szTmp=toString(m_pWellLogs[nCol-1]->GetData((float)dep),'f',DECIMALPLACESNUM,0);
|
|
}
|
|
szClipText.append(szTmp);
|
|
szClipText.append("\t");
|
|
}
|
|
szClipText.chop(1);
|
|
szClipText.append("\n");
|
|
}
|
|
|
|
QClipboard* clip=QApplication::clipboard();
|
|
clip->setText(szClipText);
|
|
|
|
}
|
|
}
|
|
void AssetCopy::onCopyColnumsData()
|
|
{
|
|
if(!m_pWellLogs.size()) return;
|
|
m_isParse=false;
|
|
if(NULL == m_menu || NULL == m_menu->parent())
|
|
return;
|
|
|
|
QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
|
|
if(NULL == m_table)
|
|
return;
|
|
//if(m_table->isVisible())
|
|
|
|
// CObjWellLogWavefile *pWaveValue=NULL;
|
|
// pWaveValue=dynamic_cast<CObjWellLogWavefile *>(m_pWellLogs[0]);
|
|
CObjWellLogTABLE *pTableValue=NULL;
|
|
// CObjDiscreteWellLog *pTableValue1=NULL;
|
|
pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
|
|
// pTableValue1=dynamic_cast<CObjDiscreteWellLog *>(m_pWellLogs[0]);
|
|
QList<QTableWidgetItem*> selItems=m_table->selectedItems();
|
|
QList<QTableWidgetSelectionRange> selRanges=m_table->selectedRanges();
|
|
float stdep=999999;
|
|
for(int i=0;i<m_pWellLogs.size();i++) {
|
|
if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep) stdep=m_pWellLogs[i]->acurveinfo.StartDepth;
|
|
}
|
|
if(selItems.size()>0)
|
|
{
|
|
QTableWidgetSelectionRange copyRange=selRanges.value(0);
|
|
|
|
int top = 0;//copyRange.topRow();
|
|
int bottom = m_table->rowCount();//copyRange.bottomRow();
|
|
int left = m_horScrolValue+copyRange.leftColumn();
|
|
int right =m_horScrolValue+copyRange.rightColumn();
|
|
|
|
if(!pTableValue/*&&!pTableValue1&&!pWaveValue*/)
|
|
{
|
|
bottom=(m_pWellLogs[0]->acurveinfo.EndDepth-m_pWellLogs[0]->acurveinfo.StartDepth)/m_pWellLogs[0]->acurveinfo.DepLevel+0.5;
|
|
}
|
|
// else if(pWaveValue) {
|
|
// bottom=(pWaveValue->waveinfo.EndDepth-pWaveValue->waveinfo.StartDepth)/pWaveValue->waveinfo.DepLevel+0.5;
|
|
// }
|
|
QString szClipText;
|
|
char buffer[200];
|
|
QString szTmp;
|
|
float dep=0;
|
|
for(int nRow = top;nRow <=bottom;nRow++)
|
|
{
|
|
if(!pTableValue/*&&!pTableValue1*/)dep=stdep+nRow*m_pWellLogs[0]->acurveinfo.DepLevel;
|
|
for(int nCol = left;nCol <=right;nCol++)
|
|
{
|
|
if(nCol==0||pTableValue/*||pTableValue1*/) {
|
|
auto pItem = m_table->item(nRow,nCol);
|
|
if(pItem)
|
|
szTmp = pItem->text();
|
|
else if(nCol==0) {
|
|
float val=szTmp.toFloat();
|
|
sprintf(buffer,"%8.3f",val+m_pWellLogs[0]->acurveinfo.DepLevel);
|
|
szTmp =buffer ;
|
|
}
|
|
}
|
|
else {
|
|
/* if(pWaveValue) szTmp=toString(pWaveValue->GetData(dep,nCol-1,buffer),'f',0);
|
|
else */szTmp=toString(m_pWellLogs[nCol-1]->GetData(dep),'f',DECIMALPLACESNUM,0);
|
|
}
|
|
szClipText.append(szTmp);
|
|
szClipText.append("\t");
|
|
}
|
|
szClipText.chop(1);
|
|
szClipText.append("\n");
|
|
}
|
|
QClipboard* clip=QApplication::clipboard();
|
|
clip->setText(szClipText);
|
|
}
|
|
}
|
|
|
|
void AssetCopy::cacheGridData(const QTableWidgetSelectionRange& m_selectionRange)
|
|
{
|
|
if(m_selectionRange.columnCount() ==0
|
|
|| m_selectionRange.rowCount() == 0
|
|
|| NULL == m_menu
|
|
|| NULL== m_menu->parent())
|
|
{
|
|
return;
|
|
}
|
|
QTableWidget *p_table=qobject_cast<QTableWidget*>( m_menu->parent());
|
|
if(NULL == p_table)
|
|
{
|
|
return;
|
|
}
|
|
m_cacheData.clear();
|
|
QTableWidgetItem *item=NULL;
|
|
|
|
int sRow= m_selectionRange.topRow();
|
|
int sCol= m_selectionRange.leftColumn();
|
|
int eRow=m_selectionRange.bottomRow();
|
|
int eCol=m_selectionRange.rightColumn();
|
|
int costCols=m_selectionRange.columnCount();
|
|
int costRows=m_selectionRange.rowCount();
|
|
|
|
QString value;
|
|
for(int r=sRow;r<=eRow;r++)
|
|
{
|
|
QMap<int,QString> colCache;
|
|
for(int c=sCol;c<=eCol;c++)
|
|
{
|
|
item=p_table->item(r,c);
|
|
if(NULL != item)
|
|
{
|
|
value=item->text();
|
|
colCache.insert(c,value);
|
|
}
|
|
}
|
|
m_cacheData.insert(r,colCache);
|
|
}
|
|
|
|
}
|
|
|
|
QString AssetCopy::itemText(int row,int col)
|
|
{
|
|
QString result="";
|
|
if( 0== m_cacheData.count())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
QMap<int,QString> colMap;
|
|
if(m_cacheData.contains(row) )
|
|
{
|
|
colMap=m_cacheData.value(row);
|
|
if(colMap.contains(col))
|
|
{
|
|
result=colMap.value(col);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
QString AssetCopy::itemParseText(int row,int col)
|
|
{
|
|
QString result="";
|
|
if( 0== m_parseCacheData.count())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
QMap<int,QString> colMap;
|
|
if(m_parseCacheData.contains(row) )
|
|
{
|
|
colMap=m_parseCacheData.value(row);
|
|
if(colMap.contains(col))
|
|
{
|
|
result=colMap.value(col);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
//////////////复制、粘贴////////////////////////////////////////////////////
|
|
QByteArray AssetCopy::seriseSelectRange(const QTableWidgetSelectionRange& selectRange)
|
|
{
|
|
QByteArray barr;
|
|
QDataStream ds(&barr,QIODevice::WriteOnly);
|
|
ds.setByteOrder(QDataStream::BigEndian);
|
|
ds<<selectRange.topRow()
|
|
<<selectRange.leftColumn()
|
|
<<selectRange.bottomRow()
|
|
<<selectRange.rightColumn();
|
|
|
|
return barr;
|
|
}
|
|
|
|
QTableWidgetSelectionRange AssetCopy::deseriseSelectRange( QByteArray& selectByte)
|
|
{
|
|
QDataStream ds(&selectByte,QIODevice::ReadOnly);
|
|
ds.setByteOrder(QDataStream::BigEndian);
|
|
int top,left,bottom,right;
|
|
ds>>top>>left>>bottom>>right;
|
|
|
|
return QTableWidgetSelectionRange(top,left,bottom,right);
|
|
}
|
|
void AssetCopy::setVerScrollValue(int value)
|
|
{
|
|
m_verScrolValue=value;
|
|
|
|
}
|
|
void AssetCopy::setHorScrollValue(int value)
|
|
{
|
|
m_horScrolValue=value;
|
|
}
|
|
void AssetCopy::parseData(const QTableWidgetSelectionRange& parse)
|
|
{
|
|
if(NULL == m_menu || NULL == m_menu->parent())
|
|
{
|
|
return;
|
|
}
|
|
|
|
QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
|
|
if(NULL == m_table)
|
|
{
|
|
return;
|
|
}
|
|
QList<QTableWidgetSelectionRange> rangeLst=m_table->selectedRanges();
|
|
if(rangeLst.size()==0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
QTableWidgetSelectionRange selRange=rangeLst.value(0);
|
|
|
|
int tableRowCount=m_table->rowCount();
|
|
int tbaleColCount=m_table->columnCount();
|
|
int top,left,bottom,right;
|
|
int selRows=selRange.rowCount();
|
|
int selCols=selRange.columnCount();
|
|
//选择一格自动填充
|
|
if(selRows==selCols && selRows==1)
|
|
{
|
|
top=selRange.topRow();
|
|
left=selRange.leftColumn();
|
|
|
|
int parRows=parse.rowCount();
|
|
int parCols=parse.columnCount();
|
|
|
|
bottom=top+parRows-1;
|
|
right=left+parCols-1;
|
|
|
|
//裁剪区域大小总行
|
|
if(parRows+top>tableRowCount)
|
|
{
|
|
bottom=tableRowCount-1;
|
|
}
|
|
//大于总列
|
|
if(parCols+left>tbaleColCount)
|
|
{
|
|
right=tbaleColCount-1;
|
|
|
|
}
|
|
|
|
}else //选择方式
|
|
{
|
|
|
|
top=selRange.topRow();
|
|
left=selRange.leftColumn();
|
|
|
|
|
|
int scCount= selRange.columnCount();
|
|
int srCount=selRange.rowCount();
|
|
int pcCount=parse.columnCount();
|
|
int prcCount=parse.rowCount();
|
|
//选中区域大于粘贴区域
|
|
if(scCount>pcCount && srCount>prcCount)
|
|
{
|
|
bottom=top+prcCount-1;
|
|
right=left+pcCount-1;
|
|
//选中区域列大于粘贴区域
|
|
}else if( scCount>pcCount && srCount<prcCount)
|
|
{
|
|
bottom=selRange.bottomRow();
|
|
right=left+pcCount-1;
|
|
//选中区域行大于粘贴区域
|
|
}else if(scCount<pcCount && srCount>prcCount)
|
|
{
|
|
bottom=top+prcCount-1;
|
|
right=selRange.rightColumn();
|
|
}
|
|
|
|
}
|
|
|
|
int begRow=parse.topRow();
|
|
int endRow=begRow+bottom-top;
|
|
int begCol=parse.leftColumn();
|
|
int endCol=begCol+right-left;
|
|
|
|
int moveRows=top- begRow;
|
|
int moveCols=left-begCol;
|
|
|
|
QString text;
|
|
int row,col;
|
|
m_parseCacheData.clear();
|
|
//取原数据粘贴数据
|
|
for(int i=begRow;i<=endRow;i++)
|
|
{
|
|
QMap<int,QString> colMap;
|
|
row=i+moveRows;
|
|
for(int j=begCol;j<=endCol;j++)
|
|
{
|
|
text=itemText(i,j);//m_table->item(i,j)->text();
|
|
|
|
col=j+moveCols;
|
|
colMap.insert(col,text);
|
|
m_table->item(row,col)->setText(text);
|
|
|
|
}
|
|
m_parseCacheData.insert(row,colMap);
|
|
}
|
|
//int top=begRow+moveRows+m_verScrolValue;
|
|
//int bottom=endRow+moveRows+m_verScrolValue;
|
|
//int left=begCol+moveCols+m_horScrolValue;
|
|
//int right=endCol+moveCols+m_horScrolValue;
|
|
|
|
int topRow=begRow+moveRows;
|
|
int bottomRow=endRow+moveRows;
|
|
int leftCol=begCol+moveCols;
|
|
int rightCol=endCol+moveCols;
|
|
|
|
|
|
QTableWidgetSelectionRange parselRange(topRow,leftCol,bottomRow,rightCol);
|
|
m_isParse=true;
|
|
emit signalParseData(parselRange);
|
|
}
|
|
void AssetCopy::restParse()
|
|
{
|
|
m_isParse=false;
|
|
}
|
|
bool AssetCopy::isParse()
|
|
{
|
|
return m_isParse;
|
|
}
|
|
void AssetCopy::changeCacheRowCol(int orgRow,int orgCol,int movRow,int movCol)
|
|
{
|
|
QMap<int,QMap<int,QString> >::iterator mItor=m_cacheData.begin();
|
|
QMap<int,QString>::iterator itor;
|
|
QMap<int,QString> mapValue;
|
|
QString value;
|
|
|
|
for(;mItor!=m_cacheData.end();mItor++)
|
|
{
|
|
if(mItor.key()==orgRow)
|
|
{
|
|
mapValue=mItor.value();
|
|
m_cacheData.erase(mItor);
|
|
m_cacheData.insert(movRow,mapValue);
|
|
mItor=m_cacheData.begin();
|
|
}
|
|
itor=mItor->begin();
|
|
for(;itor!=mItor->end();itor++)
|
|
{
|
|
if(itor.key()==orgCol)
|
|
{
|
|
value=itor.value();
|
|
mItor->erase(itor);
|
|
mItor->insert(movCol,value);
|
|
itor=mItor->begin();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void AssetCopy::reqCustomComtextMenu(const QPoint &pos)
|
|
{
|
|
emit signalReqCustomContextMenu(pos);
|
|
}
|
|
|
|
void AssetCopy::onParseData()
|
|
{
|
|
if(type == D_MultWellLogData)
|
|
{
|
|
int choose = QMessageBox::question(NULL, tr("提示"),
|
|
QString(tr("该数据格式下,粘贴后将直接存储,是否粘贴?")),
|
|
QMessageBox::Yes | QMessageBox::No);
|
|
if(choose == QMessageBox::No)
|
|
return;
|
|
}
|
|
|
|
|
|
if(!m_pWellLogs.size()) return;
|
|
if(NULL == m_menu || NULL == m_menu->parent())
|
|
return;
|
|
|
|
QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
|
|
if(NULL == m_table)
|
|
return;
|
|
|
|
QClipboard* pClip = QApplication::clipboard();
|
|
QString szText = pClip->text();
|
|
|
|
if(szText.isEmpty())
|
|
return;
|
|
|
|
int nSpace = 0;
|
|
int nDou=0;
|
|
int nTab =0;
|
|
|
|
DepthProgress MyDepthProgress2;
|
|
MyDepthProgress2.CreatProgress(0, szText.size(), "粘贴内容检查中...");
|
|
|
|
for(int nIndex =0;nIndex<szText.size();++nIndex)
|
|
{
|
|
if(szText[nIndex]=='\t')
|
|
{
|
|
nTab++;
|
|
}
|
|
else if(szText[nIndex]==' ')
|
|
{
|
|
nSpace++;
|
|
}
|
|
else if(szText[nIndex]==',')
|
|
{
|
|
nDou++;
|
|
}
|
|
|
|
MyDepthProgress2.SetDepth(nIndex);
|
|
}
|
|
|
|
int nMax = nSpace>nDou ? nSpace : nDou;
|
|
nMax = nMax>nTab ? nMax : nTab;
|
|
|
|
char rFlag;
|
|
if(nMax==nTab)
|
|
{
|
|
rFlag ='\t';
|
|
}
|
|
else if(nMax==nSpace)
|
|
{
|
|
rFlag =' ';
|
|
}
|
|
else if(nMax==nDou)
|
|
{
|
|
rFlag =',';
|
|
}
|
|
m_table->clearSelection();
|
|
QStringList rSplitList = szText.split('\n');
|
|
if(rSplitList.size()&&rSplitList[rSplitList.size()-1]=="") rSplitList.removeAt(rSplitList.size()-1);
|
|
// CObjWellLogWavefile *pWaveValue=NULL;
|
|
// pWaveValue=dynamic_cast<CObjWellLogWavefile *>(m_pWellLogs[0]);
|
|
CObjWellLogTABLE *pTableValue=NULL;
|
|
pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
|
|
// CObjDiscreteWellLog *pTableValue1=NULL;
|
|
// pTableValue1=dynamic_cast<CObjDiscreteWellLog *>(m_pWellLogs[0]);
|
|
float stdep=999999;
|
|
|
|
for(int i=0;i<m_pWellLogs.size();i++) {
|
|
if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep) stdep=m_pWellLogs[i]->acurveinfo.StartDepth;
|
|
}
|
|
float dep=0;
|
|
|
|
//起始行
|
|
int nCurrentRow = m_table->currentRow();
|
|
|
|
//纵向扩充表格
|
|
MyDepthProgress2.CreatProgress(0, rSplitList.size(), "表格建设中...");
|
|
MyDepthProgress2.SetDepth(0);
|
|
for(int cTemp = nCurrentRow; cTemp < (nCurrentRow + rSplitList.size()); cTemp++){
|
|
if(cTemp >= m_table->rowCount())
|
|
needANewLine(cTemp);
|
|
|
|
MyDepthProgress2.SetDepth(cTemp - nCurrentRow);
|
|
}
|
|
|
|
//进度条
|
|
int curprogre = 0;
|
|
MyDepthProgress2.CreatProgress(0, rSplitList.size(), "数据归位...");
|
|
MyDepthProgress2.SetDepth(0);
|
|
|
|
for(int nRow = 0; nRow < rSplitList.size(); ++nRow)
|
|
{
|
|
if(!pTableValue)
|
|
dep = stdep + (m_verScrolValue + nCurrentRow) * m_pWellLogs[0]->acurveinfo.DepLevel;
|
|
|
|
//起始列
|
|
int nCurrentColumn = m_table->currentColumn();
|
|
|
|
QStringList rColumnList = rSplitList[nRow].split(rFlag);
|
|
|
|
for(int nCol = 0; nCol < rColumnList.size(); nCol++)
|
|
{
|
|
if(pTableValue/*||pTableValue1*/) {
|
|
//空替换
|
|
if(rColumnList[nCol].isEmpty() ) rColumnList[nCol] = "";
|
|
auto pItem = m_table->item(nCurrentRow, nCurrentColumn);
|
|
|
|
//写值
|
|
if(pItem)
|
|
pItem->setText(rColumnList[nCol]);
|
|
else
|
|
{
|
|
QTableWidgetItem* pItem = new QTableWidgetItem;
|
|
pItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate);
|
|
pItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);//对齐
|
|
if(nCurrentColumn == 0) pItem->setFlags(pItem->flags() & (~Qt::ItemIsEditable));
|
|
pItem->setFont(QFont("Times",10));
|
|
|
|
m_table->setItem(nCurrentRow, nCurrentColumn, pItem);
|
|
|
|
pItem->setText(rColumnList[nCol]);
|
|
}
|
|
|
|
}
|
|
else if(nCurrentColumn){
|
|
float val=rColumnList[nCol].toFloat();
|
|
/* if(pWaveValue) pWaveValue->SetData(dep,m_horScrolValue+nCurrentColumn-1,&val);
|
|
else */m_pWellLogs[m_horScrolValue+nCurrentColumn-1]->SetData(dep,&val);
|
|
}
|
|
|
|
nCurrentColumn++;
|
|
|
|
MyDepthProgress2.SetDepth(++curprogre);
|
|
}
|
|
nCurrentRow++;
|
|
}
|
|
|
|
|
|
if(!pTableValue)
|
|
for(int i=0;i<m_pWellLogs.size();i++)
|
|
{
|
|
m_pWellLogs[i]->SetModify(true);
|
|
m_pWellLogs[i]->SaveToSLF();
|
|
}
|
|
|
|
emit saveToTempModel();
|
|
|
|
/*
|
|
CBaseDialog *pTableDialog=(CBaseDialog*)(m_table->parent());
|
|
if(pTableDialog) {
|
|
//粘贴操作不直接保存,刷新操作会重新读表格数据
|
|
//pTableDialog->ReFreshWindow(type);
|
|
}
|
|
*/
|
|
}
|
|
|
|
void AssetCopy::initPopMenu(QTableWidget *pTable, QMenu *pmenu)
|
|
{
|
|
if(pmenu == NULL)
|
|
m_menu = new QMenu(pTable);
|
|
else
|
|
m_menu = pmenu;
|
|
|
|
QIcon icon = QIcon(::GetImagePath() + "/UIMake/fuzhi.png");
|
|
QAction* action = m_menu->addAction(icon, "复制选中数据");
|
|
connect(action,SIGNAL(triggered()),this,SLOT(onCopyData()));
|
|
|
|
icon = QIcon(::GetImagePath() + "/UIMake/Hfuzhi.png");
|
|
action = m_menu->addAction(icon, "复制选中行数据");
|
|
connect(action,SIGNAL(triggered()),this,SLOT(onCopyLinesData()));
|
|
|
|
icon = QIcon(::GetImagePath() + "/UIMake/Vfuzhi.png");
|
|
action = m_menu->addAction(icon, "复制选中列数据");
|
|
connect(action,SIGNAL(triggered()),this,SLOT(onCopyColnumsData()));
|
|
|
|
icon = QIcon(::GetImagePath() + "/UIMake/pas.png");
|
|
action = m_menu->addAction(icon, "粘贴");
|
|
connect(action,SIGNAL(triggered()),this,SLOT(onParseData()));
|
|
|
|
connect(this,SIGNAL(signalReqCustomContextMenu(QPoint)),this,SLOT(onCustomContextMenuRequested(QPoint)),Qt::UniqueConnection);
|
|
}
|