图头,追加公式属性
This commit is contained in:
parent
c699f66026
commit
12b712c35d
|
|
@ -7,10 +7,10 @@
|
|||
#include "CallManage.h"
|
||||
#include "geometryutils.h"
|
||||
#include "DrawTvd.h"
|
||||
#include "qtprojectwidgets.h"
|
||||
|
||||
extern double g_dPixelPerCm;//每厘米像素数
|
||||
//extern int m_iY1;
|
||||
//extern int m_iY2;
|
||||
extern QtProjectWidgets *g_projectWidgets; //左侧工程区
|
||||
|
||||
PropertyWidget::PropertyWidget(const QString &title, QWidget *parent , Qt::WindowFlags flags )
|
||||
:QDockWidget(title,parent,flags)
|
||||
|
|
@ -35,6 +35,14 @@ PropertyWidget::PropertyWidget(const QString &title, QWidget *parent , Qt::Windo
|
|||
m_pPropertyBrowser->setFactoryForManager(m_pColorSchemeManager, colorSchemeComboBoxFactory);
|
||||
connect(m_pColorSchemeManager, SIGNAL(valueChanged(QtProperty *, const int &, bool)), this,
|
||||
SLOT(SlotPropertyChanged(QtProperty *, const int &, bool)));
|
||||
|
||||
CQtFormulaDialogFactory *formulaDlgFactory= new CQtFormulaDialogFactory();
|
||||
m_pFormulaDialogPropertyManager =new CQtFormulaDialogPropertyManager();
|
||||
m_pPropertyBrowser->setFactoryForManager(m_pFormulaDialogPropertyManager,formulaDlgFactory);
|
||||
connect( m_pFormulaDialogPropertyManager,SIGNAL(valueChanged(QtProperty *, const QVariant &)),
|
||||
this,SLOT(SlotPropertyChanged(QtProperty *, const QVariant &)) );
|
||||
connect( m_pFormulaDialogPropertyManager,SIGNAL(tableChanged(const QString &)),
|
||||
this,SLOT(onTableChanged(const QString &)) );
|
||||
}
|
||||
|
||||
PropertyWidget::~PropertyWidget()
|
||||
|
|
@ -2817,6 +2825,36 @@ QtProperty* PropertyWidget::_CreateColorSchemePropertyItem(QString strGroup, QSt
|
|||
return colorSchemeProperty;
|
||||
}
|
||||
|
||||
QtProperty* PropertyWidget::_CreateFormulaPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue)
|
||||
{
|
||||
QtProperty *pGroupItem = NULL;
|
||||
{
|
||||
QMap<QString, QtProperty *>::Iterator it = m_mapGroupItem.find(strGroup);
|
||||
if (it != m_mapGroupItem.end())
|
||||
{
|
||||
pGroupItem = it.value();
|
||||
}
|
||||
else
|
||||
{
|
||||
pGroupItem = m_pVariantManager->addProperty(QtVariantPropertyManager::groupTypeId(), strGroup);
|
||||
m_mapGroupItem[strGroup] = pGroupItem;
|
||||
m_pPropertyBrowser->addProperty(pGroupItem);
|
||||
}
|
||||
}
|
||||
|
||||
QtProperty * formulaDlgProperty = m_pFormulaDialogPropertyManager->addProperty(strPropertyCaption);
|
||||
if (formulaDlgProperty)
|
||||
{
|
||||
m_propertyData[formulaDlgProperty] = strPropertyCaption;
|
||||
pGroupItem->addSubProperty(formulaDlgProperty);
|
||||
m_pFormulaDialogPropertyManager->setValue(formulaDlgProperty,vtPropertyValue.toString());
|
||||
m_pFormulaDialogPropertyManager->setTableDataList(tableList);
|
||||
m_pFormulaDialogPropertyManager->setFieldDataList(fieldList);
|
||||
m_pFormulaDialogPropertyManager->setTableModelData(m_tableModelData);
|
||||
}
|
||||
return formulaDlgProperty;
|
||||
}
|
||||
|
||||
void PropertyWidget::initWidgetProperty(QString strUuid, int iScale)
|
||||
{
|
||||
//初始化,清空
|
||||
|
|
@ -3165,6 +3203,10 @@ void PropertyWidget::initHeadProperty(FormHead *formHead, QTableWidget *tableWid
|
|||
_CreateVariantPropertyItem("单元格", "图例", imagePath, VariantManager::filePathTypeId()); //"./image/胜利符号库/岩性符号/砂岩.png"
|
||||
_CreateVariantPropertyItem("单元格", "图例宽(cm)", m_colWidth_Img, QVariant::Double, 0, 100);
|
||||
_CreateVariantPropertyItem("单元格", "图例高(cm)", m_rowHeight_Img, QVariant::Double, 0, 100);
|
||||
|
||||
//读取图头公式
|
||||
ReadWellRoundDataToFormula();
|
||||
_CreateFormulaPropertyItem("单元格", "公式", "");
|
||||
_CreateVariantPropertyItem("单元格", "背景颜色", m_item->background().color(), QVariant::Color);
|
||||
|
||||
_CreateVariantPropertyItem("文本", "内容", item->text(), QVariant::String);
|
||||
|
|
@ -6144,11 +6186,490 @@ void PropertyWidget::changedDcaProperty(QString strProperty, QVariant varVal)
|
|||
|
||||
emit CallManage::getInstance()->sig_changeDcaProperty(variantMap);
|
||||
}
|
||||
}
|
||||
|
||||
void ReadWellMessageData(CLogIO *logio ,ViewData &tableData)
|
||||
{
|
||||
if (!logio)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//fieldList
|
||||
QVector<QString> rowData;
|
||||
Slf_FILE_MESSAGE msg;
|
||||
logio->GetFileMessage(msg);
|
||||
logio->Close();
|
||||
// delete logio;
|
||||
|
||||
QList<QStringList> valueList;
|
||||
//////////////////////////////////////1////////////////////////////////////
|
||||
QStringList partRow;
|
||||
int i=0;
|
||||
partRow <<QString("泥浆密度9")<<QString::number(msg.Mud_Density[8]);
|
||||
for (int i=0;i<4;i++)
|
||||
partRow<<QString("泥浆粘度%1").arg(i+1)<<QString::number(msg.Mud_Viscosity[i]);
|
||||
|
||||
valueList << partRow;
|
||||
|
||||
partRow.clear();
|
||||
//////////////////////////////////////2////////////////////////////////////
|
||||
for (int i=4;i<9;i++)
|
||||
partRow<<QString("泥浆粘度%1").arg(i+1)<<QString::number(msg.Mud_Viscosity[i]);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
///////////////////////////////////////3///////////////////////////////////
|
||||
partRow <<QString("泥浆粘度10")<<QString::number(msg.Mud_Viscosity[9]);
|
||||
for (i=0;i<4;i++)
|
||||
partRow<<QString("泥浆电阻%1").arg(i+1)<<QString::number(msg.Mud_Resistivity[i]);
|
||||
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
////////////////////////////////////////4//////////////////////////////////
|
||||
for (int i=4;i<9;i++)
|
||||
partRow<<QString("泥浆电阻%1").arg(i+1)<<QString::number(msg.Mud_Resistivity[i]);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
//////////////////////////////////////////5////////////////////////////////
|
||||
partRow <<QString("泥浆电阻10")<<QString::number(msg.Mud_Resistivity[9]);
|
||||
for (int i=0;i<4;i++)
|
||||
partRow<<QString("短套外径%1").arg(i+1)<<QString::number(msg.Bushing_Outside_Diameter[i]);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
/////////////////////////////////////////6/////////////////////////////////
|
||||
for (int i=4;i<9;i++)
|
||||
partRow<<QString("短套外径%1").arg(i+1)<<QString::number(msg.Bushing_Outside_Diameter[i]);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
///////////////////////////////////////////7///////////////////////////////
|
||||
partRow<<QString("短套外径10")<<QString::number(msg.Bushing_Outside_Diameter[9])
|
||||
<<QString("泥浆性能")<<QString::fromLocal8Bit(msg.Mud_Property)
|
||||
<<QString("仪器性能")<<QString::fromLocal8Bit(msg.YqType)
|
||||
<<QString("测时井深")<<QString::number(msg.LoggingDepth)
|
||||
<<QString("磁偏角")<<QString::number(msg.azca);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
/////////////////////////////////////////////8/////////////////////////////
|
||||
partRow<<QString("起始垂深")<<QString::number(msg.TVD)
|
||||
<<QString("测点X偏移")<<QString::number(msg.X0)
|
||||
<<QString("测点Y偏移")<<QString::number(msg.Y0)
|
||||
<<QString("测点Z偏移")<<QString::number(msg.Z0)
|
||||
<<QString("泥浆温度")<<QString::number(msg.Mud_Temp);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
////////////////////////////////////////////9//////////////////////////////
|
||||
partRow<<QString("备注")<<QString::fromLocal8Bit(msg.Intor)
|
||||
<<QString("IntDepths")<<QString::fromLocal8Bit(msg.IntDepths)
|
||||
<<QString("解释员")<<QString::fromLocal8Bit(msg.audit)
|
||||
<<QString("软件")<<QString::fromLocal8Bit(msg.Prog)
|
||||
<<QString("WaterLoss")<<QString::number(msg.WaterLoss);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
///////////////////////////////////////////10///////////////////////////////
|
||||
partRow<<QString("测井小队")<<QString::fromLocal8Bit(msg.Item)
|
||||
<<QString("Reserved")<<QString::fromLocal8Bit(msg.Reserved);
|
||||
for (int i=3;i<6;i++)
|
||||
partRow<<QString("套管内径%1(毫米)").arg(i+1)<<QString::number(msg.Bushing_Inside_Diameter[i]);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
//////////////////////////////////////////////11////////////////////////////
|
||||
for (int i=4;i<9;i++)
|
||||
partRow<<QString("套管内径%1(毫米)").arg(i+1)<<QString::number(msg.Bushing_Inside_Diameter[i]);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
///////////////////////////////////////////////12///////////////////////////
|
||||
partRow<<QString("套管内径10(毫米)")<<QString::number(msg.Bushing_Inside_Diameter[9]);
|
||||
for (int i=3;i<7;i++)
|
||||
partRow<<QString("套管深度%1(米)").arg(i+1)<<QString::number(msg.Bushing_Detpth[i]);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
////////////////////////////////////////////////13//////////////////////////
|
||||
for (int i=7;i<10;i++)
|
||||
partRow<<QString("套管深度%1(米)").arg(i+1)<<QString::number(msg.Bushing_Detpth[i]);
|
||||
for (int i=4;i<6;i++)
|
||||
partRow<<QString("钻头直径%1(毫米)").arg(i+1)<<QString::number(msg.Bit_Diameter[i]);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
/////////////////////////////////////////////////14/////////////////////////
|
||||
for (int i=6;i<10;i++)
|
||||
partRow<<QString("钻头直径%1(毫米)").arg(i+1)<<QString::number(msg.Bit_Diameter[i]);
|
||||
|
||||
partRow<<QString("钻头深度5(米)")<<QString::number(msg.Bit_Depth[4]);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
////////////////////////////////////////////////////15//////////////////////
|
||||
for (int i=5;i<10;i++)
|
||||
partRow<<QString("钻头深度%1(米)").arg(i+1)<<QString::number(msg.Bit_Depth[i]);
|
||||
valueList << partRow;
|
||||
partRow.clear();
|
||||
|
||||
|
||||
|
||||
rowData <<QString("井名")<<QString::fromLocal8Bit( msg.WellName)<<QString("井别")<<QString::fromLocal8Bit(msg.JB)
|
||||
<<QString("地区")<<QString::fromLocal8Bit(msg.AreaName)<<QString("补心")<<ConvertDataByFloat(msg.Kelly)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
<<QString("公司名称")<<QString::fromLocal8Bit( msg.OilCompanyName)<<QString("绘图井名")<<QString::fromLocal8Bit(msg.WellAliasName)
|
||||
<<QString("井类型")<<QString::fromLocal8Bit(msg.WellType)<<QString("大地X坐标")<<QString::number(msg.Xcoor)
|
||||
<<QString("大地Y坐标")<<QString::number(msg.Ycoor);
|
||||
|
||||
tableData <<rowData;
|
||||
|
||||
rowData.clear();
|
||||
|
||||
rowData <<QString("套管内径1(毫米)")<<ConvertDataByFloat( msg.Bushing_Inside_Diameter[0])<<QString("套管深度1(米)")<<ConvertDataByFloat(msg.Bushing_Detpth[0])
|
||||
<<QString("钻头直径1(毫米)")<<ConvertDataByFloat(msg.Bit_Diameter[0])<<QString("钻头深度1(米)")<<ConvertDataByFloat(msg.Bit_Depth[0])
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
<<QString("海拔高度")<<QString::number( msg.Altitude)<<QString("起始深度")<<QString::number(msg.StartDepth)
|
||||
<<QString("终止深度")<<QString::number(msg.EndDepth)<<QString("开钻时间")<<QString::number(msg.StartDrillDate)
|
||||
<<QString("完钻时间")<<QString::number(msg.EndDrillDate);
|
||||
tableData <<rowData;
|
||||
rowData.clear();
|
||||
|
||||
rowData <<QString("套管内径2(毫米)")<<ConvertDataByFloat( msg.Bushing_Inside_Diameter[1])<<QString("套管深度2(米)")<<ConvertDataByFloat(msg.Bushing_Detpth[1])
|
||||
<<QString("钻头直径2(毫米)")<<ConvertDataByFloat(msg.Bit_Diameter[1])<<QString("钻头深度2(米)")<<ConvertDataByFloat(msg.Bit_Depth[1])
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
<<QString("测井时间")<<QString::number( msg.LoggingDate)<<QString("测井公司")<<QString::fromLocal8Bit(msg.LogCompanyName)
|
||||
<<QString("测井队")<<QString::fromLocal8Bit(msg.LoggingTeam)<<QString("操作员")<<QString::fromLocal8Bit(msg.Operator)
|
||||
<<QString("测井系列")<<QString::fromLocal8Bit(msg.LoggingSerial);
|
||||
tableData <<rowData;
|
||||
rowData.clear();
|
||||
|
||||
rowData <<QString("套管内径3(毫米)")<<ConvertDataByFloat( msg.Bushing_Inside_Diameter[2])<<QString("套管深度3(米)")<<ConvertDataByFloat(msg.Bushing_Detpth[2])
|
||||
<<QString("钻头直径3(毫米)")<<ConvertDataByFloat(msg.Bit_Diameter[2])<<QString("钻头深度3(米)")<<ConvertDataByFloat(msg.Bit_Depth[2])
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
<<QString("井底温度")<<QString::number( msg.Well_Bottom_Temperature)
|
||||
<<QString("泥浆密度1")<<QString::number(msg.Mud_Density[0])
|
||||
<<QString("泥浆密度2")<<QString::number(msg.Mud_Density[1])
|
||||
<<QString("泥浆密度3")<<QString::number(msg.Mud_Density[2])
|
||||
<<QString("泥浆密度4")<<QString::number(msg.Mud_Density[3]);
|
||||
tableData <<rowData;
|
||||
rowData.clear();
|
||||
|
||||
rowData <<QString("")<<QString("")<<QString("")<<QString("")
|
||||
<<QString("钻头直径4(毫米)")<<ConvertDataByFloat(msg.Bit_Diameter[3])
|
||||
<<QString("钻头深度4(米)")<<ConvertDataByFloat(msg.Bit_Depth[3])
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
<<QString("泥浆密度5")<<QString::number( msg.Mud_Density[4])
|
||||
<<QString("泥浆密度6")<<QString::number(msg.Mud_Density[5])
|
||||
<<QString("泥浆密度7")<<QString::number(msg.Mud_Density[6])
|
||||
<<QString("泥浆密度8")<<QString::number(msg.Mud_Density[7])
|
||||
<<QString("泥浆密度9")<<QString::number(msg.Mud_Density[8]);
|
||||
|
||||
tableData <<rowData;
|
||||
rowData.clear();
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QStringList rowList;
|
||||
for (int i=0;i<15;i++)
|
||||
{
|
||||
rowData <<QString("")<<QString("")<<QString("")<<QString("")<<QString("")<<QString("")<<QString("")<<QString("");
|
||||
if (valueList.size()>i)
|
||||
{
|
||||
rowList=valueList.at(i);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
for (int j=0;j<rowList.size();j++)
|
||||
{
|
||||
rowData<<rowList.at(j);
|
||||
}
|
||||
}
|
||||
|
||||
tableData <<rowData;
|
||||
tableData[6-1][6-1]="米";
|
||||
rowData.clear();
|
||||
}
|
||||
}
|
||||
|
||||
QStringList GetWellMessageFields()
|
||||
{
|
||||
QStringList fields;
|
||||
fields << "AreaName" << "OilCompanyName" << "WellName" << "WellAliasName"
|
||||
<< "WellType" <<"Xcoor" << "Ycoor" <<"Altitude"
|
||||
<<"Kelly" << "StartDepth" << "EndDepth" << "StartDrillDate"
|
||||
<<"EndDrillDate" <<"LoggingDate" <<"LogCompanyName"
|
||||
<<"LoggingTeam" <<"Operator"<<"LoggingSerial"<<"WBTemperature"
|
||||
<<"Mud_Density1" <<"Mud_Density2" <<"Mud_Density3"
|
||||
<<"Mud_Density4" <<"Mud_Density5" <<"Mud_Density6"
|
||||
<<"Mud_Density7" <<"Mud_Density8" <<"Mud_Density9"<<"Mud_Density10"
|
||||
<<"Mud_Viscosity1" <<"Mud_Viscosity2" <<"Mud_Viscosity3"
|
||||
<<"Mud_Viscosity4" <<"Mud_Viscosity5" <<"Mud_Viscosity6"
|
||||
<<"Mud_Viscosity7" <<"Mud_Viscosity8" <<"Mud_Viscosity9"<<"Mud_Viscosity10"
|
||||
<<"Mud_Resistivity1" <<"Mud_Resistivity2" <<"Mud_Resistivity3"
|
||||
<<"Mud_Resistivity4" <<"Mud_Resistivity5" <<"Mud_Resistivity6"
|
||||
<<"Mud_Resistivity7" <<"Mud_Resistivity8" <<"Mud_Resistivity9"<<"Mud_Resistivity10"
|
||||
<<"Bit_Diameter1" <<"Bit_Diameter2" <<"Bit_Diameter3"
|
||||
<<"Bit_Diameter4" <<"Bit_Diameter3" <<"Bit_Diameter6"
|
||||
<<"Bit_Diameter7" <<"Bit_Diameter8" <<"Bit_Diameter9"<<"Bit_Diameter10"
|
||||
<<"Bushing_Detpth1" <<"Bushing_Detpth2" <<"Bushing_Detpth3"
|
||||
<<"Bushing_Detpth4" <<"Bushing_Detpth3" <<"Bushing_Detpth6"
|
||||
<<"Bushing_Detpth7" <<"Bushing_Detpth8" <<"Bushing_Detpth9"<<"Bushing_Detpth10"
|
||||
<<"Bushing_Inside_Diameter1" <<"Bushing_Inside_Diameter2" <<"Bushing_Inside_Diameter3"
|
||||
<<"Bushing_Inside_Diameter4" <<"Bushing_Inside_Diameter3" <<"Bushing_Inside_Diameter6"
|
||||
<<"Bushing_Inside_Diameter7" <<"Bushing_Inside_Diameter8" <<"Bushing_Inside_Diameter9"<<"Bushing_Inside_Diameter10"
|
||||
<<"Bushing_Outside_Diameter1" <<"Bushing_Outside_Diameter2" <<"Bushing_Outside_Diameter3"
|
||||
<<"Bushing_Outside_Diameter4" <<"Bushing_Outside_Diameter3" <<"Bushing_Outside_Diameter6"
|
||||
<<"Bushing_Outside_Diameter7" <<"Bushing_Outside_Diameter8" <<"Bushing_Outside_Diameter9"<<"Bushing_Outside_Diameter10"
|
||||
<<"Bit_Depth1" <<"Bit_Depth2" <<"Bit_Depth3"
|
||||
<<"Bit_Depth4" <<"Bit_Depth3" <<"Bit_Depth6"
|
||||
<<"Bit_Depth7" <<"Bit_Depth8" <<"Bit_Depth9"<<"Bit_Depth10"
|
||||
<<"Mud_Property"<<"YqType"<<"JB"<<"LoggingDepth"<<"azca"<<"TVD"
|
||||
<<"X0"<<"Y0"<<"Z0" <<"Mud_Temp"<<"Intor"<<"IntDepths"<<"audit"<<"Prog"<<"WaterLoss"
|
||||
<<"Item"<<"Reserved";
|
||||
|
||||
QStringList tempFields;
|
||||
for(int i=1;i<=18;i++)
|
||||
{
|
||||
tempFields << QString("第%1列").arg(i);
|
||||
}
|
||||
|
||||
|
||||
return tempFields;
|
||||
}
|
||||
|
||||
//图头属性--公式
|
||||
void PropertyWidget::onTableChanged(const QString &tableName)
|
||||
{
|
||||
//QString tbName=tableName;
|
||||
m_tableModelData.clear();
|
||||
fieldList.clear();
|
||||
|
||||
if (!tableName.isEmpty())
|
||||
{
|
||||
QString strSlfName = "";
|
||||
QString strWellName = "";
|
||||
QString strLeft = g_projectWidgets->getLeftTreeString_Import();
|
||||
if(strLeft.length() > 0)
|
||||
{
|
||||
QStringList list = strLeft.split("#@@#");//QString字符串分割函数
|
||||
if (list.size() > 3)
|
||||
{
|
||||
strSlfName = list[0];
|
||||
strWellName = list[1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(this, "提示", "请先选中待处理井或井次!");
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
if(strWellName != "")
|
||||
{
|
||||
QString wellFile = strSlfName;
|
||||
|
||||
if(!wellFile.isEmpty())
|
||||
{
|
||||
//获得表格头
|
||||
CLogIO *logio=new CLogIO;
|
||||
QString logFileName=wellFile;
|
||||
if(tableName ==QString("Well_Message"))
|
||||
{
|
||||
// logFileName=logFileName.replace(".slf",".well");
|
||||
}
|
||||
|
||||
if(!logio->Open(logFileName.toStdString().c_str(),CLogIO::modeRead)) {
|
||||
delete logio;
|
||||
return ;
|
||||
}
|
||||
if (tableName == "CARD")
|
||||
{
|
||||
fieldList.clear();
|
||||
int count=logio->GetObjectCount();
|
||||
char* curvename=new char[65];
|
||||
curvename[64]='\0';
|
||||
char* aliasname=new char[65];
|
||||
aliasname[64]='\0';
|
||||
QVector<QString> rowData;
|
||||
for(int i=0;i<count;i++) {
|
||||
if(logio->GetObjectStatus(i)!=OBJECT_NORMAL) continue;
|
||||
logio->GetObjectName(i,curvename,NULL,aliasname);
|
||||
short objectType=logio->GetObjectType(i);
|
||||
//表格
|
||||
if(objectType==CARD_OBJECT)
|
||||
{
|
||||
QString tbName= QString::fromLocal8Bit(curvename);
|
||||
fieldList << tbName;
|
||||
rowData<<"CARD";
|
||||
}
|
||||
}
|
||||
delete curvename;
|
||||
delete aliasname;
|
||||
m_tableModelData.clear();
|
||||
m_tableModelData<<rowData;
|
||||
}
|
||||
else if (tableName ==QString("Well_Message"))
|
||||
{
|
||||
fieldList=GetWellMessageFields();
|
||||
ReadWellMessageData(logio,m_tableModelData);
|
||||
}else
|
||||
{
|
||||
char name[100];
|
||||
strcpy(name,tableName.toStdString().c_str());
|
||||
int iIndex=logio->OpenTable(name);
|
||||
if (iIndex >=0)
|
||||
{
|
||||
//读取数据
|
||||
char buf[513];
|
||||
memset(buf,0,513);
|
||||
int fc=logio->GetTableFieldCount(iIndex);
|
||||
int rows= logio->GetTableRecordCount(iIndex);
|
||||
|
||||
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[fc+1];
|
||||
logio->GetTableFieldInfo(iIndex,field);
|
||||
for(int j=0;j<fc;j++) {
|
||||
fieldList <<field[j].Name;
|
||||
}
|
||||
int buffSize=logio->GetTableRecordLength(iIndex)+1;
|
||||
char *Buffer=new char[buffSize];
|
||||
|
||||
QTime time;
|
||||
time.start();
|
||||
int rIndex=0;
|
||||
float yy;
|
||||
|
||||
for (int r=0;r<rows;r++)
|
||||
{
|
||||
QVector<QString> rowData;
|
||||
rIndex=r+1;
|
||||
memset(Buffer,0,buffSize);
|
||||
logio->ReadTable(iIndex,rIndex,Buffer);
|
||||
int ty=0;
|
||||
int len=0;
|
||||
for (int c=0;c<fc;c++)
|
||||
{
|
||||
yy=0;
|
||||
ty=field[c].RepCode;
|
||||
if(ty!=6)
|
||||
{
|
||||
logio->GetData(ty,&Buffer[len],&yy);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
if(field[c].Reserved) {
|
||||
ty=sizeof(RepSize)+1;
|
||||
if(field[c].Reserved>0&&field[c].Reserved<logio->m_MenuNumber)
|
||||
{
|
||||
logio->GetReservedValue(yy,field[c].Reserved,Buffer,buf,buffSize-1);
|
||||
}
|
||||
else sprintf(buf,"%f",yy);
|
||||
}else
|
||||
sprintf(buf,"%f",yy);/**/
|
||||
}else
|
||||
{
|
||||
strncpy(buf,&Buffer[len],field[c].Length);
|
||||
buf[field[c].Length]='\0';/**/
|
||||
}
|
||||
if(strlen(buf)>512)
|
||||
{
|
||||
buf[512]=0;
|
||||
}
|
||||
rowData.append(toString(buf));
|
||||
len+=field[c].Length;
|
||||
}
|
||||
m_tableModelData.append(rowData);
|
||||
if (r > 2&&tableName!="测井信息表"&&tableName.indexOf("_TT")<1)
|
||||
{
|
||||
//break;
|
||||
}
|
||||
}
|
||||
delete Buffer;
|
||||
delete[] field;
|
||||
qDebug()<<"time:==========="<<time.elapsed();
|
||||
}
|
||||
logio->CloseTable(iIndex);
|
||||
}
|
||||
delete logio;
|
||||
}
|
||||
}
|
||||
if (tableName == QString("测井信息表"))
|
||||
{
|
||||
QStringList tempFields;
|
||||
for(int i=0;i<fieldList.size();i++)
|
||||
{
|
||||
tempFields << QString("第%1列").arg(i+1);
|
||||
//m_mapWellInfoFields.insert(QString("第%1列").arg(i+1),fieldList.at(i));
|
||||
}
|
||||
fieldList=tempFields;//m_mapWellInfoFields.keys();
|
||||
}
|
||||
if (m_pFormulaDialogPropertyManager)
|
||||
{
|
||||
//m_pFormulaDialogPropertyManager->setTableDataList(tableList);
|
||||
m_pFormulaDialogPropertyManager->setFieldDataList(fieldList);
|
||||
m_pFormulaDialogPropertyManager->setTableModelData(m_tableModelData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyWidget::ReadWellRoundDataToFormula()
|
||||
{
|
||||
QString tbName;
|
||||
m_tableModelData.clear();
|
||||
fieldList.clear();
|
||||
tableList.clear();
|
||||
|
||||
QString strSlfName = "";
|
||||
QString strWellName = "";
|
||||
QString strLeft = g_projectWidgets->getLeftTreeString_Import();
|
||||
if(strLeft.length() > 0)
|
||||
{
|
||||
QStringList list = strLeft.split("#@@#");//QString字符串分割函数
|
||||
if (list.size() > 3)
|
||||
{
|
||||
strSlfName = list[0];
|
||||
strWellName = list[1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(this, "提示", "请先选中待处理井或井次!");
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
if(strWellName != "")
|
||||
{
|
||||
QString wellFile = strSlfName;
|
||||
|
||||
if(!wellFile.isEmpty())
|
||||
{
|
||||
//获得表格头
|
||||
CLogIO *logio=new CLogIO;
|
||||
if(!logio->Open(wellFile.toStdString().c_str(),CLogIO::modeRead)) {
|
||||
delete logio;
|
||||
return ;
|
||||
}
|
||||
tableList << "Well_Message";
|
||||
tableList << "CARD";
|
||||
int count=logio->GetObjectCount();
|
||||
char* curvename=new char[65];
|
||||
curvename[64]='\0';
|
||||
char* aliasname=new char[65];
|
||||
aliasname[64]='\0';
|
||||
for(int i=0;i<count;i++) {
|
||||
if(logio->GetObjectStatus(i)!=OBJECT_NORMAL) continue;
|
||||
logio->GetObjectName(i,curvename,NULL,aliasname);
|
||||
short objectType=logio->GetObjectType(i);
|
||||
//表格
|
||||
if(objectType >CARD_OBJECT||objectType==0)
|
||||
{
|
||||
tbName= QString::fromLocal8Bit(curvename);
|
||||
tableList << tbName;
|
||||
}
|
||||
}
|
||||
delete curvename;
|
||||
delete aliasname;
|
||||
char name[100];
|
||||
if (tableList.size() == 0)
|
||||
{
|
||||
delete logio;
|
||||
return;
|
||||
}
|
||||
tbName=tableList.value(0);
|
||||
if (tbName.isEmpty())
|
||||
{
|
||||
delete logio;
|
||||
return;
|
||||
}
|
||||
fieldList=GetWellMessageFields();
|
||||
ReadWellMessageData(logio,m_tableModelData);
|
||||
delete logio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "variantmanager.h"
|
||||
#include "variantfactory.h"
|
||||
#include "ColorSchemeComboBox.h"
|
||||
#include "QtFormulaDialogfactory.h"
|
||||
//
|
||||
#include "forminfo.h"
|
||||
#include "formhead.h"
|
||||
|
|
@ -89,6 +90,8 @@
|
|||
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
typedef QVector<QVector<QString> > ViewData;
|
||||
|
||||
/**
|
||||
* @class PropertyWidget
|
||||
* @brief 统一属性服务
|
||||
|
|
@ -107,6 +110,7 @@ private:
|
|||
QtTreePropertyBrowser *m_pPropertyBrowser;
|
||||
QtVariantPropertyManager *m_pVariantManager;
|
||||
QtColorSchemeComboBoxPropertyManager * m_pColorSchemeManager;
|
||||
CQtFormulaDialogPropertyManager * m_pFormulaDialogPropertyManager;
|
||||
|
||||
public:
|
||||
QString m_strUuid;
|
||||
|
|
@ -168,6 +172,10 @@ public:
|
|||
int m_sdVerticalDepthPosition = 0;
|
||||
int m_sdElevationVerticalDepthPosition = 0;
|
||||
|
||||
//图头,成果表
|
||||
QStringList tableList,fieldList;
|
||||
ViewData m_tableModelData;
|
||||
|
||||
public:
|
||||
QWidget* GetPropertyWidget();
|
||||
|
||||
|
|
@ -176,6 +184,9 @@ public:
|
|||
void _CreateEnumPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, QStringList listValue);
|
||||
|
||||
QtProperty* _CreateColorSchemePropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, int nclr);
|
||||
QtProperty* _CreateFormulaPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue);
|
||||
//读取图头公式
|
||||
void ReadWellRoundDataToFormula();
|
||||
|
||||
void InitCurrentViewInfo(bool bAll = true); //初始化属性,清空
|
||||
void initWidgetProperty(QString strUuid, int iScale); //可视解释整体属性
|
||||
|
|
@ -302,6 +313,7 @@ public:
|
|||
public slots:
|
||||
void SlotPropertyChanged(QtProperty *property, const QVariant &variant);
|
||||
void SlotPropertyChanged(QtProperty *property, const int &val, bool islinestyle);
|
||||
void onTableChanged(const QString &tableName);
|
||||
};
|
||||
|
||||
extern PropertyWidget* PropertyService();
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ int g_iPageStep = 1500;
|
|||
QString g_strSlfName = "";
|
||||
QString g_strWellName = "";
|
||||
|
||||
QtProjectWidgets *g_projectWidgets = nullptr; //左侧工程区
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
|
|
@ -429,6 +431,7 @@ void MainWindow::dockLayout()
|
|||
m_projectWidgets = new QtProjectWidgets(this);
|
||||
dock1->setWidget(m_projectWidgets);
|
||||
addDockWidget(Qt::LeftDockWidgetArea,dock1);
|
||||
g_projectWidgets = m_projectWidgets;
|
||||
|
||||
//属性编辑器
|
||||
m_propertyWidget = PropertyService();
|
||||
|
|
|
|||
870
qtpropertybrowser/QtFormulaDialogfactory.cpp
Normal file
870
qtpropertybrowser/QtFormulaDialogfactory.cpp
Normal file
|
|
@ -0,0 +1,870 @@
|
|||
#include "QtFormulaDialogfactory.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QApplication>
|
||||
#include <QMap>
|
||||
#include <QFileDialog>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QHeaderView>
|
||||
#include <QKeyEvent>
|
||||
#include <QLineEdit>
|
||||
//#include "BaseObject.h"
|
||||
//#include "ObjectID.h"
|
||||
//#include "DialogFactory.h"
|
||||
///*#include "geo"*/
|
||||
//using namespace pai::datamodel;
|
||||
|
||||
static inline void setupTreeViewEditorMargin(QLayout *lt)
|
||||
{
|
||||
enum { DecorationMargin = 4 };
|
||||
if (QApplication::layoutDirection() == Qt::LeftToRight)
|
||||
lt->setContentsMargins(DecorationMargin, 0, 0, 0);
|
||||
else
|
||||
lt->setContentsMargins(0, 0, DecorationMargin, 0);
|
||||
}
|
||||
|
||||
template <class Value, class PrivateData>
|
||||
static Value getData(const QMap<const QtProperty *, PrivateData> &propertyMap,
|
||||
Value PrivateData::*data,
|
||||
const QtProperty *property, const Value &defaultValue = Value())
|
||||
{
|
||||
typedef QMap<const QtProperty *, PrivateData> PropertyToData;
|
||||
typedef typename PropertyToData::const_iterator PropertyToDataConstIterator;
|
||||
const PropertyToDataConstIterator it = propertyMap.constFind(property);
|
||||
if (it == propertyMap.constEnd())
|
||||
return defaultValue;
|
||||
return it.value().*data;
|
||||
}
|
||||
|
||||
template <class Value, class PrivateData>
|
||||
static Value getValue(const QMap<const QtProperty *, PrivateData> &propertyMap,
|
||||
const QtProperty *property, const Value &defaultValue = Value())
|
||||
{
|
||||
return getData<Value>(propertyMap, &PrivateData::val, property, defaultValue);
|
||||
}
|
||||
|
||||
CQtFormulaDialogFactory::CQtFormulaDialogFactory(QObject *parent)
|
||||
: QtAbstractEditorFactory<CQtFormulaDialogPropertyManager>(parent), d_ptr(new CQtFormulaDialogFactoryPrivate())
|
||||
{
|
||||
d_ptr->q_ptr = this;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this factory, and all the widgets it has created.
|
||||
*/
|
||||
CQtFormulaDialogFactory::~CQtFormulaDialogFactory()
|
||||
{
|
||||
qDeleteAll(d_ptr->m_editorToProperty.keys());
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Reimplemented from the QtAbstractEditorFactory class.
|
||||
*/
|
||||
void CQtFormulaDialogFactory::connectPropertyManager(CQtFormulaDialogPropertyManager *manager)
|
||||
{
|
||||
connect(manager, SIGNAL(valueChanged(QtProperty*, QVariant)),
|
||||
this, SLOT(slotPropertyChanged(QtProperty*, QVariant)));
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Reimplemented from the QtAbstractEditorFactory class.
|
||||
*/
|
||||
QWidget *CQtFormulaDialogFactory::createEditor(CQtFormulaDialogPropertyManager *manager, QtProperty *property,
|
||||
QWidget *parent)
|
||||
{
|
||||
|
||||
CQtFormulaDialogEditWidget *editor = d_ptr->createEditor(property, parent);
|
||||
connect(editor,SIGNAL(tableChanged(const QString&)),manager,SIGNAL(tableChanged(const QString&)),Qt::UniqueConnection);
|
||||
editor->tableDataList=manager->tableDataList;
|
||||
editor->fieldList=manager->fieldDataList;
|
||||
editor->tableModelData=manager->tableModelData;
|
||||
connect(manager,SIGNAL(fieldListChanged(const QStringList&)),editor,SLOT(setComboxFieldDataList(const QStringList&)),Qt::UniqueConnection);
|
||||
connect(manager,SIGNAL(tableListChanged(const QStringList&)),editor,SLOT(setComboxTableDataList(const QStringList&)),Qt::UniqueConnection);
|
||||
|
||||
connect(manager,SIGNAL(tableModelDataChanged(const ViewData&)),editor,SLOT(setTableModeData(const ViewData&)),Qt::UniqueConnection);
|
||||
|
||||
//connect(manager,SIGNAL(signalCallFormulaDialogAction()),editor,SLOT(buttonClicked()));
|
||||
|
||||
//editor->defaultDir=manager->defaultDir;
|
||||
//editor->filter=manager->filter;
|
||||
editor->setValue(manager->value(property));
|
||||
|
||||
|
||||
connect(editor, SIGNAL(valueChanged(QString)), this, SLOT(slotSetValue(QString)),Qt::UniqueConnection);
|
||||
connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)),Qt::UniqueConnection);
|
||||
return editor;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Reimplemented from the QtAbstractEditorFactory class.
|
||||
*/
|
||||
void CQtFormulaDialogFactory::disconnectPropertyManager(CQtFormulaDialogPropertyManager *manager)
|
||||
{
|
||||
disconnect(manager, SIGNAL(valueChanged(QtProperty*,QString)),
|
||||
this, SLOT(slotPropertyChanged(QtProperty*,QString)));
|
||||
}
|
||||
|
||||
|
||||
void CQtFormulaDialogFactoryPrivate::slotPropertyChanged(QtProperty *property, QString value)
|
||||
{
|
||||
|
||||
const PropertyToEditorListMap::iterator it = m_createdEditors.find(property);
|
||||
if (it == m_createdEditors.end())
|
||||
return;
|
||||
QListIterator<CQtFormulaDialogEditWidget *> itEditor(it.value());
|
||||
|
||||
while (itEditor.hasNext())
|
||||
itEditor.next()->setValue(value);
|
||||
}
|
||||
|
||||
void CQtFormulaDialogFactoryPrivate::slotSetValue(QString value)
|
||||
{
|
||||
QObject *object = q_ptr->sender();
|
||||
const QMap<CQtFormulaDialogEditWidget *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd();
|
||||
for (QMap<CQtFormulaDialogEditWidget *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor)
|
||||
if (itEditor.key() == object) {
|
||||
QtProperty *property = itEditor.value();
|
||||
CQtFormulaDialogPropertyManager *manager = q_ptr->propertyManager(property);
|
||||
if (!manager)
|
||||
return;
|
||||
manager->setValue(property, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
CQtFormulaDialogPropertyManager::CQtFormulaDialogPropertyManager(QObject *parent)
|
||||
: QtAbstractPropertyManager(parent), d_ptr(new CQtFormulaDialogPropertyManagerPrivate)
|
||||
{
|
||||
d_ptr->q_ptr = this;
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this manager, and all the properties it has created.
|
||||
*/
|
||||
CQtFormulaDialogPropertyManager::~CQtFormulaDialogPropertyManager()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the given \a property's value which is an index in the
|
||||
list returned by enumNames()
|
||||
|
||||
If the given property is not managed by this manager, this
|
||||
function returns -1.
|
||||
|
||||
\sa enumNames(), setValue()
|
||||
*/
|
||||
QString CQtFormulaDialogPropertyManager::value(const QtProperty *property) const
|
||||
{
|
||||
return d_ptr->m_values.value(property, QString());
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the given \a property's list of enum names.
|
||||
|
||||
\sa value(), setEnumNames()
|
||||
*/
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QString CQtFormulaDialogPropertyManager::valueText(const QtProperty *property) const
|
||||
{
|
||||
const CQtFormulaDialogPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
||||
if (it == d_ptr->m_values.constEnd())
|
||||
return QString();
|
||||
QString avalue=*it;
|
||||
QString strFilePath = avalue;//得到用户输入的文件名
|
||||
strFilePath.replace("\\","/");
|
||||
QString file = strFilePath.split("/").takeLast();
|
||||
//QString filename = file.split(".").takeFirst();
|
||||
return file;
|
||||
}
|
||||
|
||||
void CQtFormulaDialogPropertyManager::setFieldDataList(const QStringList &fieldList)
|
||||
{
|
||||
fieldDataList=fieldList;
|
||||
emit fieldListChanged(fieldList);
|
||||
}
|
||||
void CQtFormulaDialogPropertyManager::setTableDataList(const QStringList &tableList)
|
||||
{
|
||||
tableDataList=tableList;
|
||||
emit tableListChanged(tableList);
|
||||
}
|
||||
void CQtFormulaDialogPropertyManager::setTableModelData(const ViewData &modelData)
|
||||
{
|
||||
tableModelData=modelData;
|
||||
emit tableModelDataChanged(modelData);
|
||||
}
|
||||
/*!
|
||||
\fn void QtLineStyleEnumPropertyManager::setValue(QtProperty *property, int value)
|
||||
|
||||
Sets the value of the given \a property to \a value.
|
||||
|
||||
The specified \a value must be less than the size of the given \a
|
||||
property's enumNames() list, and larger than (or equal to) 0.
|
||||
|
||||
\sa value(), valueChanged()
|
||||
*/
|
||||
void CQtFormulaDialogPropertyManager::setValue(QtProperty *property, QString val)
|
||||
{
|
||||
QString strFilePath = val;//得到用户输入的文件名
|
||||
strFilePath.replace("\\","/");
|
||||
QString file = strFilePath.split("/").takeLast();
|
||||
//QString filename = file.split(".").takeFirst();
|
||||
const CQtFormulaDialogPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
||||
if (it == d_ptr->m_values.end())
|
||||
return;
|
||||
|
||||
*it = file;
|
||||
//m_label->setText(filename);
|
||||
emit propertyChanged(property);
|
||||
emit valueChanged(property, val);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the given \a property's list of enum names to \a
|
||||
enumNames. The \a property's current value is reset to 0
|
||||
indicating the first item of the list.
|
||||
|
||||
If the specified \a enumNames list is empty, the \a property's
|
||||
current value is set to -1.
|
||||
|
||||
\sa enumNames(), enumNamesChanged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Sets the given \a property's map of enum values to their icons to \a
|
||||
enumIcons.
|
||||
|
||||
Each enum value can have associated icon. This association is represented with passed \a enumIcons map.
|
||||
|
||||
\sa enumNames(), enumNamesChanged()
|
||||
*/
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void CQtFormulaDialogPropertyManager::initializeProperty(QtProperty *property)
|
||||
{
|
||||
d_ptr->m_values[property] = "可疑气油层";
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void CQtFormulaDialogPropertyManager::uninitializeProperty(QtProperty *property)
|
||||
{
|
||||
d_ptr->m_values.remove(property);
|
||||
}
|
||||
|
||||
//void CQtFormulaDialogPropertyManager::onGraphicsHeadCellFormula(const QString &formla)
|
||||
//{
|
||||
// cellFormula=formla;
|
||||
//}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//CQTtGeoStraEditWidget
|
||||
CQtFormulaDialogEditWidget::CQtFormulaDialogEditWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_label(new QLabel),
|
||||
m_button(new QToolButton),
|
||||
m_formula(""),
|
||||
m_tableCombox(new QComboBox),
|
||||
m_fieldCombox(new QComboBox),
|
||||
m_tableView(new QTableWidget),
|
||||
btnAccpted(new QPushButton),
|
||||
btnCancel(new QPushButton),
|
||||
formulaDialog(new QDialog),
|
||||
lblTable(new QLabel),
|
||||
lblField(new QLabel),
|
||||
lblSmall(new QLabel),
|
||||
m_smallBox(new QSpinBox),
|
||||
m_listWidget(new QListWidget),
|
||||
btnAddCompute(new QPushButton),
|
||||
btnSubtractCompute(new QPushButton),
|
||||
btnMultiplyCompute(new QPushButton),
|
||||
btnDivideCompute(new QPushButton),
|
||||
btnAppend(new QPushButton),
|
||||
btnUndo(new QPushButton),
|
||||
editline(new QLineEdit()),
|
||||
Noline(new QLineEdit()),
|
||||
NoLabel(new QLabel),
|
||||
m_lable1(new QLabel)
|
||||
{
|
||||
|
||||
m_computeSymbol<<"+"<<"-"<<"*"<<"/";
|
||||
QHBoxLayout *lt = new QHBoxLayout(this);
|
||||
setupTreeViewEditorMargin(lt);
|
||||
lt->setSpacing(0);
|
||||
lt->addWidget(m_label);
|
||||
lt->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
|
||||
|
||||
m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
|
||||
m_button->setFixedWidth(20);
|
||||
setFocusProxy(m_button);
|
||||
setFocusPolicy(m_button->focusPolicy());
|
||||
m_button->setText(tr("..."));
|
||||
m_button->installEventFilter(this);
|
||||
|
||||
lt->addWidget(m_button);
|
||||
m_label->setText(m_formula);
|
||||
m_tableView->setMouseTracking(true);
|
||||
formulaDialog->setLayout(NULL);
|
||||
initConnect();
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::initConnect()
|
||||
{
|
||||
connect(m_tableCombox,SIGNAL(currentIndexChanged(const QString &)),this,SIGNAL(tableChanged(const QString &)),Qt::UniqueConnection);
|
||||
connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
|
||||
connect(btnAccpted,SIGNAL(clicked()),this,SLOT(onAcceptOk()),Qt::UniqueConnection);
|
||||
connect(btnCancel,SIGNAL(clicked()),this,SLOT(onCancel()),Qt::UniqueConnection);
|
||||
|
||||
|
||||
connect(btnAddCompute,SIGNAL(clicked()),this,SLOT(onAddCompute()),Qt::UniqueConnection);
|
||||
connect(btnSubtractCompute,SIGNAL(clicked()),this,SLOT(onSubtractCompute()),Qt::UniqueConnection);
|
||||
connect(btnMultiplyCompute,SIGNAL(clicked()),this,SLOT(onMultipyCompute()),Qt::UniqueConnection);
|
||||
connect(btnDivideCompute,SIGNAL(clicked()),this,SLOT(onDivideCompute()),Qt::UniqueConnection);
|
||||
|
||||
connect(btnAppend,SIGNAL(clicked()),this,SLOT(onAppend()),Qt::UniqueConnection);
|
||||
connect(btnUndo,SIGNAL(clicked()),this,SLOT(onUndo()),Qt::UniqueConnection);
|
||||
connect(m_tableView,SIGNAL(cellPressed(int, int)),this,SLOT(onCellPressed(int,int)));
|
||||
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::onCellPressed(int row,int column)
|
||||
{
|
||||
int rows=m_tableView->rowCount();
|
||||
int cols=m_tableView->columnCount();
|
||||
if (row >=0 && column < cols)
|
||||
{
|
||||
m_fieldCombox->setCurrentIndex(column);
|
||||
}
|
||||
QTableWidgetItem *item=m_tableView->item(row,column);
|
||||
QString cellText,cellSam;
|
||||
if (item)
|
||||
{
|
||||
cellText=item->text();
|
||||
}
|
||||
if (cellText.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool isOk=false;
|
||||
float value=cellText.toFloat(&isOk);
|
||||
int leftMid=0,canSize=0,orgSize=0;
|
||||
if (isOk)
|
||||
{
|
||||
|
||||
leftMid= cellText.lastIndexOf(".");
|
||||
|
||||
if (leftMid >=0)
|
||||
{
|
||||
leftMid=cellText.size()-(leftMid+1);
|
||||
cellSam=cellText.right(leftMid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
m_smallBox->setValue(cellSam.size());
|
||||
|
||||
}
|
||||
CQtFormulaDialogEditWidget::~CQtFormulaDialogEditWidget()
|
||||
{
|
||||
if(formulaDialog)
|
||||
{
|
||||
delete formulaDialog;
|
||||
formulaDialog=NULL;
|
||||
}
|
||||
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::setComboxFieldDataList()
|
||||
{
|
||||
|
||||
m_fieldCombox->clear();
|
||||
foreach(const QString &itemText,fieldList)
|
||||
{
|
||||
m_fieldCombox->addItem(itemText);
|
||||
}
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::setComboxTableDataList()
|
||||
{
|
||||
|
||||
m_tableCombox->clear();
|
||||
foreach(const QString &itemText,tableDataList)
|
||||
{
|
||||
m_tableCombox->addItem(itemText);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CQtFormulaDialogEditWidget::setComboxFieldDataList(const QStringList& list)
|
||||
{
|
||||
fieldList=list;
|
||||
setComboxFieldDataList();
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::setComboxTableDataList(const QStringList& list)
|
||||
{
|
||||
tableDataList=list;
|
||||
setComboxTableDataList();
|
||||
|
||||
}
|
||||
|
||||
void CQtFormulaDialogEditWidget::setTableModeData(const ViewData & tableData)
|
||||
{
|
||||
tableModelData=tableData;
|
||||
bindTableData();
|
||||
}
|
||||
|
||||
void CQtFormulaDialogEditWidget::setValue(const QString &c)
|
||||
{
|
||||
if (m_formula != c)
|
||||
{
|
||||
m_formula = c;
|
||||
m_label->setText(c);
|
||||
}
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::showFormulaDlg()
|
||||
{
|
||||
|
||||
setComboxFieldDataList();
|
||||
initUI();
|
||||
//bindTableData();
|
||||
QString formulaStr("=TABLE(%1:%2:%3.%4)");
|
||||
|
||||
QString tableName,fieldName,mapFieldKey,mapFieldValue;
|
||||
int tbCount=0,fieldCount=0;
|
||||
bindCellFormula();
|
||||
if(formulaDialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
tbCount=m_tableCombox->count();
|
||||
fieldCount=m_fieldCombox->count();
|
||||
if(tbCount == 0 || fieldCount ==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
formulaStr=combinationFormual();
|
||||
setValue(formulaStr);
|
||||
emit valueChanged(formulaStr);
|
||||
}
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::initUI()
|
||||
{
|
||||
bool applayLayout=NULL == formulaDialog->layout();
|
||||
if(applayLayout)
|
||||
{
|
||||
|
||||
setComboxTableDataList();
|
||||
//formulaDialog->setWindowFlags(Qt::FramelessWindowHint);
|
||||
|
||||
m_tableView->setParent(formulaDialog);
|
||||
m_tableCombox->setParent(formulaDialog);
|
||||
m_fieldCombox->setParent(formulaDialog);
|
||||
btnAccpted->setParent(formulaDialog);
|
||||
btnCancel->setParent(formulaDialog);
|
||||
lblTable->setParent(formulaDialog);
|
||||
editline->setParent(formulaDialog);
|
||||
Noline->setParent(formulaDialog);
|
||||
m_lable1->setParent(formulaDialog);
|
||||
lblField->setParent(formulaDialog);
|
||||
|
||||
lblSmall->setParent(formulaDialog);
|
||||
m_smallBox->setParent(formulaDialog);
|
||||
m_listWidget->setParent(formulaDialog);
|
||||
btnAddCompute->setParent(formulaDialog);
|
||||
btnSubtractCompute->setParent(formulaDialog);
|
||||
btnMultiplyCompute->setParent(formulaDialog);
|
||||
btnDivideCompute->setParent(formulaDialog);
|
||||
btnAppend->setParent(formulaDialog);
|
||||
btnUndo->setParent(formulaDialog);
|
||||
m_smallBox->setMinimum(0);
|
||||
m_smallBox->setMaximum(6);
|
||||
m_smallBox->setValue(0);
|
||||
|
||||
formulaDialog->resize(800,500);
|
||||
|
||||
m_lable1->setText("输入附加信息");
|
||||
btnAccpted->setText("确定");
|
||||
btnCancel->setText("取消");
|
||||
lblTable->setText("选择数据表");
|
||||
lblField->setText("选择字段");
|
||||
lblSmall->setText("小数位数");
|
||||
btnAddCompute->setText("+");
|
||||
btnSubtractCompute->setText("-");
|
||||
btnMultiplyCompute->setText("*");
|
||||
btnDivideCompute->setText("/");
|
||||
btnAppend->setText("添加");
|
||||
btnUndo->setText("回退");
|
||||
|
||||
|
||||
QHBoxLayout *hMainboxLayout=new QHBoxLayout(formulaDialog);
|
||||
QVBoxLayout *vRightBoxLayout=new QVBoxLayout(formulaDialog);
|
||||
QVBoxLayout *vboxLayout=new QVBoxLayout(formulaDialog);
|
||||
QHBoxLayout *hboxLayout=new QHBoxLayout(formulaDialog);
|
||||
QHBoxLayout *bottomhboxLayout=new QHBoxLayout(formulaDialog);
|
||||
|
||||
hboxLayout->addWidget(lblTable);
|
||||
hboxLayout->addWidget(m_tableCombox);
|
||||
|
||||
hboxLayout->addWidget(lblField);
|
||||
hboxLayout->addWidget(m_fieldCombox);
|
||||
|
||||
hboxLayout->addWidget(lblSmall);
|
||||
hboxLayout->addWidget(m_smallBox);
|
||||
|
||||
hboxLayout->addStretch();
|
||||
vboxLayout->addItem(hboxLayout);
|
||||
vboxLayout->addWidget(m_listWidget,1);
|
||||
//
|
||||
vboxLayout->addWidget(m_tableView,2);
|
||||
|
||||
bottomhboxLayout->addStretch();
|
||||
bottomhboxLayout->addWidget(m_lable1);
|
||||
bottomhboxLayout->addWidget(editline);
|
||||
bottomhboxLayout->addWidget(btnAccpted);
|
||||
bottomhboxLayout->addWidget(btnCancel);
|
||||
vboxLayout->addStretch();
|
||||
vboxLayout->addItem(bottomhboxLayout);
|
||||
|
||||
vRightBoxLayout->addWidget(btnAddCompute);
|
||||
vRightBoxLayout->addWidget(btnSubtractCompute);
|
||||
vRightBoxLayout->addWidget(btnMultiplyCompute);
|
||||
vRightBoxLayout->addWidget(btnDivideCompute);
|
||||
vRightBoxLayout->addStretch();
|
||||
vRightBoxLayout->addWidget(btnAppend);
|
||||
vRightBoxLayout->addWidget(btnUndo);
|
||||
vRightBoxLayout->addStretch();
|
||||
NoLabel->setText("特定行");
|
||||
vRightBoxLayout->addWidget(NoLabel);
|
||||
vRightBoxLayout->addWidget(Noline);
|
||||
|
||||
vRightBoxLayout->addStretch();
|
||||
|
||||
hMainboxLayout->addItem(vboxLayout);
|
||||
hMainboxLayout->addItem(vRightBoxLayout);
|
||||
|
||||
formulaDialog->setWindowTitle("选择表及字段");
|
||||
|
||||
}
|
||||
}
|
||||
QString CQtFormulaDialogEditWidget::combinationFormual()
|
||||
{
|
||||
QString formual;
|
||||
int rows=m_listWidget->count();
|
||||
if(rows == 0)
|
||||
{
|
||||
return formual;
|
||||
}
|
||||
QListWidgetItem *item=NULL;
|
||||
QStringList symbolList;
|
||||
for(int i=0;i<rows;i++)
|
||||
{
|
||||
item=m_listWidget->item(i);
|
||||
if(item)
|
||||
{
|
||||
symbolList << item->text();
|
||||
}
|
||||
}
|
||||
formual=symbolList.join("");
|
||||
return formual;
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::onAcceptOk()
|
||||
{
|
||||
formulaDialog->accept();
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::onCancel()
|
||||
{
|
||||
formulaDialog->close();
|
||||
}
|
||||
|
||||
void CQtFormulaDialogEditWidget::bindTableData()
|
||||
{
|
||||
|
||||
int cols=0;
|
||||
int rows=m_tableView->rowCount();
|
||||
QAbstractItemModel *itemModel=m_tableView->model();
|
||||
if (itemModel)
|
||||
{
|
||||
itemModel->removeRows(0,rows);
|
||||
}
|
||||
// 表字段
|
||||
cols= fieldList.size();
|
||||
// 表数据
|
||||
rows=tableModelData.size();
|
||||
if(rows == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_tableView->setRowCount(rows);
|
||||
m_tableView->setColumnCount(cols);
|
||||
m_tableView->setHorizontalHeaderLabels(fieldList);
|
||||
m_tableView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_tableView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||
|
||||
QHeaderView *headView= m_tableView->horizontalHeader();
|
||||
headView->setStretchLastSection(true);
|
||||
itemModel=m_tableView->model();
|
||||
|
||||
QString text;
|
||||
for(int r=0;r<rows;r++)
|
||||
{
|
||||
for (int c=0;c<cols;c++)
|
||||
{
|
||||
text=tableModelData.at(r).value(c);
|
||||
if (itemModel)
|
||||
{
|
||||
itemModel->setData(itemModel->index(r,c),text,Qt::DisplayRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bindCellFormula();
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::buttonClicked()
|
||||
{
|
||||
//QFileDialog fileDialog;
|
||||
showFormulaDlg();
|
||||
}
|
||||
|
||||
//compute slots
|
||||
void CQtFormulaDialogEditWidget::onAddCompute()
|
||||
{
|
||||
appendComputeSymbol(btnAddCompute);
|
||||
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::onSubtractCompute()
|
||||
{
|
||||
appendComputeSymbol(btnSubtractCompute);
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::onMultipyCompute()
|
||||
{
|
||||
appendComputeSymbol(btnMultiplyCompute);
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::onDivideCompute()
|
||||
{
|
||||
appendComputeSymbol(btnDivideCompute);
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::appendComputeSymbol(QPushButton *button)
|
||||
{
|
||||
|
||||
QString symbolStr;
|
||||
bool isAppend=false;
|
||||
if (button)
|
||||
{
|
||||
symbolStr=button->text().trimmed();
|
||||
isAppend=isAppendValidate(symbolStr);
|
||||
if (isAppend)
|
||||
{
|
||||
m_listWidget->addItem(symbolStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool CQtFormulaDialogEditWidget::isAppendValidate(const QString &rowItem)
|
||||
{
|
||||
int rows=m_listWidget->count();
|
||||
bool isValidate=false;
|
||||
QString symbolStr;
|
||||
if(rows == 0 && !m_computeSymbol.contains(rowItem))
|
||||
{
|
||||
isValidate=true;
|
||||
|
||||
}else if(rows > 0)
|
||||
{
|
||||
QListWidgetItem *item= m_listWidget->item(rows-1);
|
||||
symbolStr=item->text().trimmed();
|
||||
if(m_computeSymbol.contains(rowItem) && !m_computeSymbol.contains(symbolStr))
|
||||
{
|
||||
isValidate=true;
|
||||
|
||||
}else if (m_computeSymbol.contains(symbolStr) && !m_computeSymbol.contains(rowItem))
|
||||
{
|
||||
isValidate=true;
|
||||
}
|
||||
}
|
||||
return isValidate;
|
||||
}
|
||||
// fun
|
||||
void CQtFormulaDialogEditWidget::onAppend()
|
||||
{
|
||||
int tbCount=m_tableCombox->count();
|
||||
int fieldCount=m_fieldCombox->count();
|
||||
if(tbCount == 0 || fieldCount ==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString formualTable=buildTableFormulaRow();
|
||||
bool isAppend=isAppendValidate(formualTable);
|
||||
if(isAppend)
|
||||
{
|
||||
m_listWidget->addItem(formualTable);
|
||||
}
|
||||
|
||||
}
|
||||
void CQtFormulaDialogEditWidget::onUndo()
|
||||
{
|
||||
int rows=m_listWidget->count();
|
||||
if(rows == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int index=rows -1;
|
||||
QListWidgetItem* item=m_listWidget->takeItem(index);
|
||||
if (item)
|
||||
{
|
||||
delete item;
|
||||
item=NULL;
|
||||
}
|
||||
|
||||
//QListWidgetItem *item= m_listWidget->item(rows-1);
|
||||
//m_listWidget->removeItemWidget(item);
|
||||
}
|
||||
|
||||
QString CQtFormulaDialogEditWidget::buildTableFormulaRow(const QString &computeFlag)
|
||||
{
|
||||
QString formulaStr("=TABLE(%1:%2:%3.%4)");
|
||||
QString tableName,fieldName;
|
||||
int recordNo=0,reatinNum=m_smallBox->value();
|
||||
if(computeFlag.isEmpty())
|
||||
{
|
||||
tableName=m_tableCombox->currentText();
|
||||
fieldName=m_fieldCombox->currentText();
|
||||
recordNo=m_tableView->currentRow()+1;
|
||||
if(editline->text()!="")
|
||||
{
|
||||
tableName="QString";
|
||||
fieldName=editline->text();
|
||||
recordNo=-1;
|
||||
}
|
||||
if(Noline->text()!="") {
|
||||
formulaStr=formulaStr.arg(tableName).arg(fieldName).arg(Noline->text()).arg(reatinNum);
|
||||
}
|
||||
else formulaStr=formulaStr.arg(tableName).arg(fieldName).arg(recordNo).arg(reatinNum);
|
||||
}else
|
||||
{
|
||||
formulaStr=computeFlag;
|
||||
|
||||
}
|
||||
return formulaStr;
|
||||
}
|
||||
//QString GetImagePath()
|
||||
//{
|
||||
// static QString imgpath;
|
||||
// if(imgpath!="") return imgpath;
|
||||
// QString strImagePath;
|
||||
// {
|
||||
// QString strPathTmp = QCoreApplication::applicationDirPath() + QDir::separator();
|
||||
// strImagePath = QDir::toNativeSeparators( strPathTmp );
|
||||
// QDir dir;
|
||||
// if( dir.exists( strPathTmp + "image" ) )
|
||||
// {
|
||||
// return strPathTmp + "image" + QDir::separator();
|
||||
// }else
|
||||
// {
|
||||
// strImagePath = strImagePath+".."+ "/LogPlus/image/";
|
||||
// }
|
||||
// }
|
||||
// imgpath=strImagePath;
|
||||
// return imgpath;
|
||||
//}
|
||||
bool CQtFormulaDialogEditWidget::eventFilter(QObject *obj, QEvent *ev)
|
||||
{
|
||||
if (obj == m_button) {
|
||||
switch (ev->type()) {
|
||||
case QEvent::KeyPress:
|
||||
case QEvent::KeyRelease: { // Prevent the QToolButton from handling Enter/Escape meant control the delegate
|
||||
switch (static_cast<const QKeyEvent*>(ev)->key()) {
|
||||
case Qt::Key_Escape:
|
||||
case Qt::Key_Enter:
|
||||
case Qt::Key_Return:
|
||||
ev->ignore();
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(obj, ev);
|
||||
}
|
||||
|
||||
void CQtFormulaDialogEditWidget::bindCellFormula()
|
||||
{
|
||||
//QString formulaStr("=TABLE(%1:%2:%3.%4)");
|
||||
QStringList formulaLst;
|
||||
QString formula;
|
||||
QString computeChar;
|
||||
int sIndex=0,eIndex=0;
|
||||
|
||||
if (m_formula.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while(true)
|
||||
{
|
||||
eIndex = m_formula.indexOf(")",sIndex);
|
||||
if (eIndex == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
int tSize=m_formula.size();
|
||||
eIndex++;
|
||||
|
||||
if (eIndex != m_formula.size())
|
||||
{
|
||||
computeChar= m_formula.mid(eIndex,1);
|
||||
}
|
||||
|
||||
formula = m_formula.mid(sIndex,eIndex-sIndex);
|
||||
formulaLst << formula;
|
||||
if (!computeChar.isEmpty())
|
||||
{
|
||||
formulaLst << computeChar;
|
||||
eIndex++;
|
||||
computeChar=QString("");
|
||||
}
|
||||
|
||||
sIndex=eIndex;
|
||||
}
|
||||
|
||||
// 清空公式列表
|
||||
int rows=m_listWidget->count();
|
||||
while(rows > 0)
|
||||
{
|
||||
QListWidgetItem* item=m_listWidget->takeItem(0);
|
||||
if (item)
|
||||
{
|
||||
delete item;
|
||||
item=NULL;
|
||||
}
|
||||
rows=m_listWidget->count();
|
||||
}
|
||||
|
||||
// 绑定到listview
|
||||
for (int i=0;i < formulaLst.size(); i++)
|
||||
{
|
||||
formula=formulaLst.value(i);
|
||||
bool isAppend=isAppendValidate(formula);
|
||||
if(isAppend)
|
||||
{
|
||||
m_listWidget->addItem(formula);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
197
qtpropertybrowser/QtFormulaDialogfactory.h
Normal file
197
qtpropertybrowser/QtFormulaDialogfactory.h
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
#ifndef QTFORMULADIALOGFACTORY_H
|
||||
#define QTFORMULADIALOGFACTORY_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QToolButton>
|
||||
#include <QComboBox>
|
||||
#include <QTableWidget>
|
||||
#include <QDialog>
|
||||
#include <QPushButton>
|
||||
#include <QListWidget>
|
||||
#include <QSpinBox>
|
||||
#include <QStack>
|
||||
#include <QMap>
|
||||
#include "qteditorfactory.h"
|
||||
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class CQtFormulaDialogfactoryPrivate;
|
||||
class CQtFormulaDialogPropertyManagerPrivate;
|
||||
|
||||
typedef QVector<QVector<QString> > ViewData;
|
||||
|
||||
class QTPROPERTYBROWSER_EXPORT CQtFormulaDialogPropertyManager : public QtAbstractPropertyManager
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CQtFormulaDialogPropertyManager(QObject *parent = 0);
|
||||
~CQtFormulaDialogPropertyManager();
|
||||
|
||||
QString value(const QtProperty *property) const;
|
||||
QStringList enumNames(const QtProperty *property) const;
|
||||
QMap<int, QString> enumIcons(const QtProperty *property) const;
|
||||
|
||||
void setFieldDataList(const QStringList &fieldList);
|
||||
void setTableDataList(const QStringList &tableList);
|
||||
void setTableModelData(const ViewData &modelData);
|
||||
|
||||
|
||||
|
||||
QStringList tableDataList;
|
||||
QStringList fieldDataList;
|
||||
ViewData tableModelData;
|
||||
//QMap<QString,QString> m_mapWellInfoFields;
|
||||
//QString cellFormula;
|
||||
//QString defaultDir;
|
||||
//QString filter;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setValue(QtProperty *property, QString val);
|
||||
/* void onGraphicsHeadCellFormula(const QString &formla);*/
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(QtProperty *property, const QVariant &);
|
||||
|
||||
void tableChanged(const QString &);
|
||||
|
||||
void fieldListChanged(const QStringList&);
|
||||
void tableListChanged(const QStringList&);
|
||||
void tableModelDataChanged(const ViewData&);
|
||||
|
||||
|
||||
protected:
|
||||
QString valueText(const QtProperty *property) const;
|
||||
virtual void initializeProperty(QtProperty *property);
|
||||
virtual void uninitializeProperty(QtProperty *property);
|
||||
private:
|
||||
QScopedPointer<CQtFormulaDialogPropertyManagerPrivate> d_ptr;
|
||||
|
||||
|
||||
Q_DECLARE_PRIVATE(CQtFormulaDialogPropertyManager)
|
||||
Q_DISABLE_COPY(CQtFormulaDialogPropertyManager)
|
||||
};
|
||||
|
||||
|
||||
|
||||
class QTPROPERTYBROWSER_EXPORT CQtFormulaDialogPropertyManagerPrivate
|
||||
{
|
||||
CQtFormulaDialogPropertyManager *q_ptr;
|
||||
Q_DECLARE_PUBLIC(CQtFormulaDialogPropertyManager)
|
||||
public:
|
||||
|
||||
typedef QMap<const QtProperty *, QString> PropertyValueMap;
|
||||
PropertyValueMap m_values;
|
||||
};
|
||||
|
||||
|
||||
class CQtFormulaDialogFactoryPrivate;
|
||||
|
||||
class QTPROPERTYBROWSER_EXPORT CQtFormulaDialogFactory : public QtAbstractEditorFactory<CQtFormulaDialogPropertyManager>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CQtFormulaDialogFactory(QObject *parent = 0);
|
||||
~CQtFormulaDialogFactory();
|
||||
|
||||
protected:
|
||||
void connectPropertyManager(CQtFormulaDialogPropertyManager *manager);
|
||||
QWidget *createEditor(CQtFormulaDialogPropertyManager *manager, QtProperty *property,
|
||||
QWidget *parent);
|
||||
void disconnectPropertyManager(CQtFormulaDialogPropertyManager *manager);
|
||||
private:
|
||||
QScopedPointer<CQtFormulaDialogFactoryPrivate> d_ptr;
|
||||
Q_DECLARE_PRIVATE(CQtFormulaDialogFactory)
|
||||
Q_DISABLE_COPY(CQtFormulaDialogFactory)
|
||||
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, QString))
|
||||
Q_PRIVATE_SLOT(d_func(), void slotSetValue(QString))
|
||||
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CQtFormulaDialogEditWidget;
|
||||
class QTPROPERTYBROWSER_EXPORT CQtFormulaDialogFactoryPrivate : public EditorFactoryPrivate<CQtFormulaDialogEditWidget>
|
||||
{
|
||||
CQtFormulaDialogFactory *q_ptr;
|
||||
Q_DECLARE_PUBLIC(CQtFormulaDialogFactory)
|
||||
public:
|
||||
|
||||
void slotPropertyChanged(QtProperty *property, QString value);
|
||||
void slotSetValue(QString value);
|
||||
};
|
||||
|
||||
// CQtFormulaDialogEditWidget
|
||||
QString GetImagePath();
|
||||
class CQtFormulaDialogEditWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CQtFormulaDialogEditWidget(QWidget *parent);
|
||||
~CQtFormulaDialogEditWidget();
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
QStringList tableDataList;
|
||||
QStringList fieldList;
|
||||
ViewData tableModelData;
|
||||
QMap<QString,QString> mapWellInfoFields;
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void setValue(const QString &value);
|
||||
void setComboxFieldDataList(const QStringList& list);
|
||||
void setComboxTableDataList(const QStringList& list);
|
||||
void setTableModeData(const ViewData &tableData);
|
||||
void buttonClicked();
|
||||
private Q_SLOTS:
|
||||
|
||||
void onAcceptOk();
|
||||
void onCancel();
|
||||
//compute slots
|
||||
void onAddCompute();
|
||||
void onSubtractCompute();
|
||||
void onMultipyCompute();
|
||||
void onDivideCompute();
|
||||
// fun
|
||||
void onAppend();
|
||||
void onUndo();
|
||||
void onCellPressed(int row, int column);
|
||||
Q_SIGNALS:
|
||||
void valueChanged(const QString &value);
|
||||
void tableChanged(const QString &tableName);
|
||||
private:
|
||||
void initUI();
|
||||
void showFormulaDlg();
|
||||
void bindTableData();
|
||||
void setComboxFieldDataList();
|
||||
void setComboxTableDataList();
|
||||
void initConnect();
|
||||
QString buildTableFormulaRow(const QString &computeFlag="");
|
||||
bool isAppendValidate(const QString &rowItem);
|
||||
void appendComputeSymbol(QPushButton *button);
|
||||
QString combinationFormual();
|
||||
void bindCellFormula();
|
||||
|
||||
private:
|
||||
QString m_formula;
|
||||
QLabel *m_label;
|
||||
QToolButton *m_button;
|
||||
QComboBox *m_tableCombox,*m_fieldCombox;
|
||||
|
||||
QTableWidget *m_tableView;
|
||||
QListWidget *m_listWidget;
|
||||
QSpinBox *m_smallBox;
|
||||
QPushButton *btnAccpted,*btnCancel,*btnAddCompute,*btnSubtractCompute,
|
||||
*btnMultiplyCompute,*btnDivideCompute,*btnAppend,*btnUndo;
|
||||
QLabel *m_lable1;
|
||||
QLineEdit *editline;
|
||||
QLabel*NoLabel;
|
||||
QLineEdit *Noline;
|
||||
QDialog *formulaDialog;
|
||||
QLabel *lblTable,*lblField,*lblSmall;
|
||||
QList<QString> m_computeSymbol;
|
||||
};
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
#endif
|
||||
|
|
@ -43,6 +43,7 @@ SOURCES += $$PWD/qtpropertybrowser.cpp \
|
|||
$$PWD/qtpropertybrowserutils.cpp \
|
||||
ColorSchemeComboBox.cpp \
|
||||
Gradient.cpp \
|
||||
QtFormulaDialogfactory.cpp \
|
||||
qtColorSchemeComboBox.cpp \
|
||||
qtComboBox.cpp
|
||||
|
||||
|
|
@ -56,6 +57,7 @@ HEADERS += $$PWD/qtpropertybrowser.h \
|
|||
$$PWD/qtpropertybrowserutils_p.h \
|
||||
ColorSchemeComboBox.h \
|
||||
Gradient.h \
|
||||
QtFormulaDialogfactory.h \
|
||||
qtColorSchemeComboBox.h \
|
||||
qtComboBox.h
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user