project model generate version v0.5
This commit is contained in:
parent
42c02f6e42
commit
e18ff1a59a
|
|
@ -45,6 +45,8 @@ set(H_HEADER_FILES
|
||||||
include/toolPage.h
|
include/toolPage.h
|
||||||
include/toolBox.h
|
include/toolBox.h
|
||||||
include/loadPageDlg.h
|
include/loadPageDlg.h
|
||||||
|
include/projectModelDlg.h
|
||||||
|
include/renameModel.h
|
||||||
|
|
||||||
common/include/global.h
|
common/include/global.h
|
||||||
common/include/dataBase.h
|
common/include/dataBase.h
|
||||||
|
|
@ -65,6 +67,8 @@ set(CPP_SOURCE_FILES
|
||||||
source/toolPage.cpp
|
source/toolPage.cpp
|
||||||
source/toolBox.cpp
|
source/toolBox.cpp
|
||||||
source/loadPageDlg.cpp
|
source/loadPageDlg.cpp
|
||||||
|
source/projectModelDlg.cpp
|
||||||
|
source/renameModel.cpp
|
||||||
|
|
||||||
common/source/dataBase.cpp
|
common/source/dataBase.cpp
|
||||||
common/source/httpInterface.cpp
|
common/source/httpInterface.cpp
|
||||||
|
|
@ -73,6 +77,8 @@ set(UI_FILES
|
||||||
ui/mainwindow.ui
|
ui/mainwindow.ui
|
||||||
ui/graphicElementsPanel.ui
|
ui/graphicElementsPanel.ui
|
||||||
ui/loadPageDlg.ui
|
ui/loadPageDlg.ui
|
||||||
|
ui/projectModelDlg.ui
|
||||||
|
ui/renameModel.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
# 包含源文件目录
|
# 包含源文件目录
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,50 @@
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
struct attributeGroup //属性组(元模)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
QString group;
|
||||||
|
QString groupName;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dataType //数据类型(元模)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
QString dataType;
|
||||||
|
QString databaseType;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct attribute //属性表(元模属性字段)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
QString attribute; //属性名
|
||||||
|
QString dataType; //数据类型
|
||||||
|
int lengthPrecision=0; //长度限制(varchar)
|
||||||
|
int scale=0; //小数点位数
|
||||||
|
QString defaultValue; //默认值
|
||||||
|
QString valueRange; //数值范围
|
||||||
|
int attributeGroup=0; //属性组
|
||||||
|
int isNotNull=0; //是否非空
|
||||||
|
int isPrimaryKey=0; //是否主键
|
||||||
|
};
|
||||||
|
|
||||||
|
struct modelAttribute //模型-属性对应表(元模在此表查找)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
QString modelType; //元模名
|
||||||
|
int attributeId; //属性id
|
||||||
|
};
|
||||||
|
|
||||||
|
struct modelConnectivity //模型连接性表(元模是否可以连接)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
QString fromModel; //属性名
|
||||||
|
QString toModel;
|
||||||
|
int connectivity=0; //是否可连
|
||||||
|
};
|
||||||
|
|
||||||
|
//==================================================
|
||||||
struct availableID //可用id
|
struct availableID //可用id
|
||||||
{
|
{
|
||||||
int componentId = -1;
|
int componentId = -1;
|
||||||
|
|
@ -125,18 +169,48 @@ public:
|
||||||
void parallelUpdate();
|
void parallelUpdate();
|
||||||
|
|
||||||
QJsonObject QstringToJson(QString jsonString);
|
QJsonObject QstringToJson(QString jsonString);
|
||||||
|
public:
|
||||||
|
//***********元模
|
||||||
|
bool getAttributeGroup(); //获取属性组信息
|
||||||
|
bool getDataType(); //获取数据类型信息
|
||||||
|
bool getAttribute(); //获取属性
|
||||||
|
bool getModelAttribute(); //获取元模
|
||||||
|
bool getModelConnectivity(); //获取连接性
|
||||||
|
|
||||||
|
QMap<int,attributeGroup> AttributeGroup() const {return _attributeGroup;}
|
||||||
|
QMap<int,dataType> DataType() const {return _dataType;}
|
||||||
|
QMap<int,attribute> Attribute() const {return _attribute;}
|
||||||
|
QMap<int,modelAttribute> ModelAttribute() const {return _modelAttribute;}
|
||||||
|
QMap<int,modelConnectivity> ModelConnectivity() const {return _modelConnectivity;}
|
||||||
|
//***********工程模
|
||||||
|
bool createProjectManager(); //生成记录表,包含工程模名称,属性组名,启用和关闭的属性字段(json类型)[一个属性组建一个表]
|
||||||
|
bool insertProjectManager(const QString& name,const QString& tag,const QString& metaModel,const QString& groupName,int linkType,QJsonObject checkState);
|
||||||
|
bool getProjectManager();
|
||||||
|
QMap<QString,QJsonObject> getCheckStateFromManager(const QString& sProject); //获取当前工程模型所有属性的选择状态 <属性名,选择状态>
|
||||||
|
bool createDynamicTable(const QString&, const QStringList&);
|
||||||
|
private:
|
||||||
|
QMap<int,attributeGroup> _attributeGroup; //属性组的组
|
||||||
|
QMap<int,dataType> _dataType; //数据类型组
|
||||||
|
QMap<int,attribute> _attribute; //属性组
|
||||||
|
QMap<int,modelAttribute> _modelAttribute; //元模组
|
||||||
|
QMap<int,modelConnectivity> _modelConnectivity; //连接性组
|
||||||
private:
|
private:
|
||||||
void initial();
|
void initial();
|
||||||
|
//bool createProjectDB();
|
||||||
|
//void initialProjectDB();
|
||||||
void readXML();
|
void readXML();
|
||||||
static DataBase* instance;
|
static DataBase* instance;
|
||||||
static int _id;
|
static int _id;
|
||||||
QSqlDatabase db;
|
QSqlDatabase db;
|
||||||
|
//QSqlDatabase prodb;
|
||||||
QString m_sFileName;
|
QString m_sFileName;
|
||||||
QString _DataBaseType;
|
QString _DataBaseType;
|
||||||
QString _DataBaseName;
|
QString _DataBaseName;
|
||||||
|
//QString _ProjectDB; //工程模数据库名
|
||||||
QString _HostName;
|
QString _HostName;
|
||||||
int _Port;
|
int _Port;
|
||||||
QString _UserName;
|
QString _UserName;
|
||||||
QString _PassWord;
|
QString _PassWord;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // DATABASE_H
|
#endif // DATABASE_H
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,20 @@ enum DiagramMode //组态图模式
|
||||||
DM_edit = 0,
|
DM_edit = 0,
|
||||||
DM_run
|
DM_run
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Attribute //元模属性字段对照
|
||||||
|
{
|
||||||
|
Id = Qt::UserRole + 1,
|
||||||
|
Attribute = Qt::UserRole + 2,
|
||||||
|
DataType = Qt::UserRole + 3,
|
||||||
|
LengthPrecision = Qt::UserRole + 4,
|
||||||
|
Scale = Qt::UserRole + 5,
|
||||||
|
DefaultValue = Qt::UserRole + 6,
|
||||||
|
ValueRange = Qt::UserRole + 7,
|
||||||
|
AttributeGroup = Qt::UserRole + 8,
|
||||||
|
IsNotNull = Qt::UserRole + 9,
|
||||||
|
IsPrimaryKey = Qt::UserRole + 10
|
||||||
|
};
|
||||||
//Q_ENUM_NS(GraphicsItemType)
|
//Q_ENUM_NS(GraphicsItemType)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,9 @@ DataBase::DataBase()
|
||||||
{
|
{
|
||||||
m_sFileName = QString("setting.xml");
|
m_sFileName = QString("setting.xml");
|
||||||
initial();
|
initial();
|
||||||
//insertComponent(QUuid::createUuid(),QString("111"),QString("111"),QString("111"),QString("111"),QString("111"),QString("111"),QString("111"),1,true,1,QJsonObject(),QJsonObject(),QJsonObject(),1,1);
|
//createProjectDB();
|
||||||
//insertPage(QString("111"),QString("111"),4,QJsonObject(),QJsonObject(),QString("111"),1);
|
//initialProjectDB();
|
||||||
//insertStation(1,QString("111"),QString("111"),true,1);
|
createProjectManager();
|
||||||
//insertGrid(QString("111"),QString("111"),1);
|
|
||||||
//insertZone(1,QString("111"),QString("111"),1);
|
|
||||||
//insertTopologic(1,QUuid::createUuid(),QUuid::createUuid(),1,QString("111"),1);
|
|
||||||
//updateId();
|
|
||||||
//deleteComponentById(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataBase::~DataBase()
|
DataBase::~DataBase()
|
||||||
|
|
@ -35,11 +30,11 @@ DataBase::~DataBase()
|
||||||
void DataBase::initial()
|
void DataBase::initial()
|
||||||
{
|
{
|
||||||
readXML();
|
readXML();
|
||||||
if (QSqlDatabase::contains("qt_sql_default_connection"))
|
if (QSqlDatabase::contains(_DataBaseName))
|
||||||
db = QSqlDatabase::database("qt_sql_default_connection");
|
db = QSqlDatabase::database(_DataBaseName);
|
||||||
else
|
else
|
||||||
db = QSqlDatabase::addDatabase(_DataBaseType);
|
db = QSqlDatabase::addDatabase(_DataBaseType,_DataBaseName);
|
||||||
//db = QSqlDatabase::addDatabase(_DataBaseType);
|
|
||||||
db.setDatabaseName(_DataBaseName);
|
db.setDatabaseName(_DataBaseName);
|
||||||
db.setHostName(_HostName);
|
db.setHostName(_HostName);
|
||||||
db.setPort(_Port);
|
db.setPort(_Port);
|
||||||
|
|
@ -48,12 +43,45 @@ void DataBase::initial()
|
||||||
db.setPassword(_PassWord);
|
db.setPassword(_PassWord);
|
||||||
|
|
||||||
if (db.open()) {
|
if (db.open()) {
|
||||||
qDebug()<<"success";
|
qDebug()<<"baseDB success";
|
||||||
} else {
|
} else {
|
||||||
qDebug()<<"failed";
|
qDebug()<<"baseDB failed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*bool DataBase::createProjectDB()
|
||||||
|
{
|
||||||
|
QSqlQuery query(db);
|
||||||
|
QString sql = QString("CREATE DATABASE %1").arg(_ProjectDB);
|
||||||
|
if (!query.exec(sql)) {
|
||||||
|
qDebug() << "创建数据库失败:" << query.lastError().text();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBase::initialProjectDB()
|
||||||
|
{
|
||||||
|
if (QSqlDatabase::contains(_ProjectDB))
|
||||||
|
prodb = QSqlDatabase::database(_ProjectDB);
|
||||||
|
else
|
||||||
|
prodb = QSqlDatabase::addDatabase(_DataBaseType,_ProjectDB);
|
||||||
|
|
||||||
|
prodb.setDatabaseName(_ProjectDB);
|
||||||
|
prodb.setHostName(_HostName);
|
||||||
|
prodb.setPort(_Port);
|
||||||
|
// 需要改成自己的用户名和密码
|
||||||
|
prodb.setUserName(_UserName);
|
||||||
|
prodb.setPassword(_PassWord);
|
||||||
|
|
||||||
|
if (prodb.open()) {
|
||||||
|
qDebug()<<"ProjectDB success";
|
||||||
|
} else {
|
||||||
|
//qDebug()<<"ProjectDB failed";
|
||||||
|
qDebug()<<prodb.lastError();
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
void DataBase::updateId()
|
void DataBase::updateId()
|
||||||
{
|
{
|
||||||
if(db.open())
|
if(db.open())
|
||||||
|
|
@ -791,10 +819,12 @@ void DataBase::readXML()
|
||||||
QXmlStreamAttributes attributes = m_pReader->attributes();
|
QXmlStreamAttributes attributes = m_pReader->attributes();
|
||||||
QString tpe = attributes.value("Type").toString();
|
QString tpe = attributes.value("Type").toString();
|
||||||
QString sName = attributes.value("Name").toString();
|
QString sName = attributes.value("Name").toString();
|
||||||
|
//QString sProDB = attributes.value("ProjectDB").toString();
|
||||||
if (tpe == QString("PostgreSQL"))
|
if (tpe == QString("PostgreSQL"))
|
||||||
{
|
{
|
||||||
_DataBaseType = QString("QPSQL");
|
_DataBaseType = QString("QPSQL");
|
||||||
_DataBaseName = sName;
|
_DataBaseName = sName;
|
||||||
|
//_ProjectDB = sProDB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(m_pReader->name() == QString("HostName"))
|
else if(m_pReader->name() == QString("HostName"))
|
||||||
|
|
@ -847,3 +877,315 @@ QJsonObject DataBase::QstringToJson(QString jsonString)
|
||||||
QJsonObject jsonObject = jsonDocument.object();
|
QJsonObject jsonObject = jsonDocument.object();
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
//=================================元模=============================================//
|
||||||
|
bool DataBase::getAttributeGroup()
|
||||||
|
{
|
||||||
|
if(db.open())
|
||||||
|
{
|
||||||
|
QSqlQuery qry(db);
|
||||||
|
bool success = qry.exec("SELECT * FROM attribute_group");
|
||||||
|
if (!success) {
|
||||||
|
qDebug()<<qry.lastError().text();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (qry.next())
|
||||||
|
{
|
||||||
|
int id = qry.value(0).toInt();
|
||||||
|
QString group = qry.value(1).toString();
|
||||||
|
QString groupName = qry.value(2).toString();
|
||||||
|
|
||||||
|
if(!_attributeGroup.contains(id))
|
||||||
|
{
|
||||||
|
attributeGroup ag;
|
||||||
|
ag.id = id;
|
||||||
|
ag.group = group;
|
||||||
|
ag.groupName = groupName;
|
||||||
|
_attributeGroup.insert(id,ag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qry.finish();
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::getDataType()
|
||||||
|
{
|
||||||
|
if(db.open())
|
||||||
|
{
|
||||||
|
QSqlQuery qry(db);
|
||||||
|
bool success = qry.exec("SELECT * FROM data_type");
|
||||||
|
if (!success) {
|
||||||
|
qDebug()<<qry.lastError().text();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (qry.next())
|
||||||
|
{
|
||||||
|
int id = qry.value(0).toInt();
|
||||||
|
QString dt = qry.value(1).toString();
|
||||||
|
QString dbt = qry.value(2).toString();
|
||||||
|
|
||||||
|
if(!_dataType.contains(id))
|
||||||
|
{
|
||||||
|
dataType type;
|
||||||
|
type.id = id;
|
||||||
|
type.dataType = dt;
|
||||||
|
type.databaseType = dbt;
|
||||||
|
_dataType.insert(id,type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qry.finish();
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::getAttribute()
|
||||||
|
{
|
||||||
|
if(db.open())
|
||||||
|
{
|
||||||
|
QSqlQuery qry(db);
|
||||||
|
bool success = qry.exec("SELECT * FROM attribute");
|
||||||
|
if (!success) {
|
||||||
|
qDebug()<<qry.lastError().text();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (qry.next())
|
||||||
|
{
|
||||||
|
int id = qry.value(0).toInt();
|
||||||
|
QString att = qry.value(1).toString(); //属性名
|
||||||
|
QString dt = qry.value(2).toString(); //类型名
|
||||||
|
int len = qry.value(3).toInt(); //类型长度
|
||||||
|
int scale = qry.value(4).toInt(); //类型精度
|
||||||
|
QString dv = qry.value(5).toString(); //默认值
|
||||||
|
QString vr = qry.value(6).toString(); //范围
|
||||||
|
int ag = qry.value(7).toInt(); //属性组
|
||||||
|
int inn = qry.value(8).toInt(); //非空
|
||||||
|
int ipk = qry.value(9).toInt(); //是否主键
|
||||||
|
|
||||||
|
if(!_dataType.contains(id))
|
||||||
|
{
|
||||||
|
attribute attribute;
|
||||||
|
attribute.id = id;
|
||||||
|
attribute.attribute = att;
|
||||||
|
attribute.dataType = dt;
|
||||||
|
attribute.lengthPrecision = len;
|
||||||
|
attribute.scale = scale;
|
||||||
|
attribute.defaultValue = dv;
|
||||||
|
attribute.valueRange = vr;
|
||||||
|
attribute.attributeGroup = ag;
|
||||||
|
attribute.isNotNull = inn;
|
||||||
|
attribute.isPrimaryKey = ipk;
|
||||||
|
|
||||||
|
_attribute.insert(id,attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qry.finish();
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::getModelAttribute()
|
||||||
|
{
|
||||||
|
if(db.open())
|
||||||
|
{
|
||||||
|
QSqlQuery qry(db);
|
||||||
|
bool success = qry.exec("SELECT * FROM model_attribute");
|
||||||
|
if (!success) {
|
||||||
|
qDebug()<<qry.lastError().text();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (qry.next())
|
||||||
|
{
|
||||||
|
int id = qry.value(0).toInt();
|
||||||
|
QString mt = qry.value(1).toString(); //模型名
|
||||||
|
int ai = qry.value(2).toInt(); //属性id
|
||||||
|
|
||||||
|
if(!_modelAttribute.contains(id))
|
||||||
|
{
|
||||||
|
modelAttribute model;
|
||||||
|
model.id = id;
|
||||||
|
model.modelType = mt;
|
||||||
|
model.attributeId = ai;
|
||||||
|
_modelAttribute.insert(id,model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qry.finish();
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::getModelConnectivity()
|
||||||
|
{
|
||||||
|
if(db.open())
|
||||||
|
{
|
||||||
|
QSqlQuery qry(db);
|
||||||
|
bool success = qry.exec("SELECT * FROM model_connectivity");
|
||||||
|
if (!success) {
|
||||||
|
qDebug()<<qry.lastError().text();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (qry.next())
|
||||||
|
{
|
||||||
|
int id = qry.value(0).toInt();
|
||||||
|
QString fm = qry.value(1).toString(); //from
|
||||||
|
QString tm = qry.value(2).toString(); //to
|
||||||
|
int con = qry.value(3).toInt(); //是否可联
|
||||||
|
|
||||||
|
if(!_modelConnectivity.contains(id))
|
||||||
|
{
|
||||||
|
modelConnectivity connect;
|
||||||
|
connect.id = id;
|
||||||
|
connect.fromModel = fm;
|
||||||
|
connect.toModel = tm;
|
||||||
|
connect.connectivity = con;
|
||||||
|
|
||||||
|
_modelConnectivity.insert(id,connect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qry.finish();
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//=================================工程模===========================================//
|
||||||
|
bool DataBase::createProjectManager()
|
||||||
|
{
|
||||||
|
if(db.open())
|
||||||
|
{
|
||||||
|
QSqlQuery qry(db);
|
||||||
|
//qry.exec("CREATE SEQUENCE IF NOT EXISTS project_manager_id_seq;");
|
||||||
|
//qry.finish();
|
||||||
|
//id integer NOT NULL DEFAULT nextval('project_manager_id_seq'::regclass) PRIMARY KEY,
|
||||||
|
QString createTableSQL = R"(
|
||||||
|
CREATE TABLE IF NOT EXISTS project_manager (
|
||||||
|
id SERIAL NOT NULL PRIMARY KEY,
|
||||||
|
name VARCHAR(64) NOT NULL,
|
||||||
|
tag VARCHAR(64) NOT NULL,
|
||||||
|
meta_model VARCHAR(64) NOT NULL,
|
||||||
|
group_name VARCHAR(64) NOT NULL,
|
||||||
|
link_type integer NOT NULL DEFAULT 0,
|
||||||
|
check_state JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||||
|
)
|
||||||
|
)";
|
||||||
|
|
||||||
|
if (!qry.exec(createTableSQL)) {
|
||||||
|
qDebug() << "Error creating table:" << qry.lastError().text();
|
||||||
|
} else {
|
||||||
|
qDebug() << "Table 'project_manager' created successfully!";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::insertProjectManager(const QString& name,const QString& tag,const QString& metaModel,const QString& groupName,int linkType,QJsonObject checkState)
|
||||||
|
{
|
||||||
|
if(db.open())
|
||||||
|
{
|
||||||
|
QSqlQuery qry(db);
|
||||||
|
|
||||||
|
QJsonDocument checkDoc(checkState);
|
||||||
|
QString strCheck = checkDoc.toJson(QJsonDocument::Compact);
|
||||||
|
|
||||||
|
|
||||||
|
qry.prepare("INSERT INTO project_manager(name, tag, meta_model, group_name, linkType, check_state) VALUES (?, ?, ?, ?, ?, ?)");
|
||||||
|
qry.bindValue(0,name);
|
||||||
|
qry.bindValue(1,tag);
|
||||||
|
qry.bindValue(2,metaModel);
|
||||||
|
qry.bindValue(3,groupName);
|
||||||
|
qry.bindValue(4,linkType);
|
||||||
|
qry.bindValue(5,strCheck);
|
||||||
|
bool res = qry.exec();
|
||||||
|
QString str = qry.lastQuery();
|
||||||
|
if(!res)
|
||||||
|
{
|
||||||
|
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||||
|
}
|
||||||
|
qry.clear();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::getProjectManager()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString,QJsonObject> DataBase::getCheckStateFromManager(const QString& sProject)
|
||||||
|
{
|
||||||
|
QMap<QString,QJsonObject> map;
|
||||||
|
if(sProject == QString::fromWCharArray(L"新建"))
|
||||||
|
{
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
if(db.open())
|
||||||
|
{
|
||||||
|
QSqlQuery qry(db);
|
||||||
|
|
||||||
|
qry.prepare("SELECT group_name, check_state FROM project_manager WHERE tag = ?");
|
||||||
|
qry.bindValue(0,sProject);
|
||||||
|
bool res = qry.exec();
|
||||||
|
QString str = qry.lastQuery();
|
||||||
|
if(!res)
|
||||||
|
{
|
||||||
|
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||||
|
qry.clear();
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (qry.next())
|
||||||
|
{
|
||||||
|
QString group = qry.value(0).toString();
|
||||||
|
QString state = qry.value(1).toString();
|
||||||
|
QJsonObject jsonObj = QstringToJson(state);
|
||||||
|
qry.clear();
|
||||||
|
map.insert(group,jsonObj);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::createDynamicTable(const QString &tableName, const QStringList &fields)
|
||||||
|
{
|
||||||
|
if(db.open())
|
||||||
|
{
|
||||||
|
QString createTableSQL = "CREATE TABLE IF NOT EXISTS " + tableName + " (";
|
||||||
|
|
||||||
|
for (const QString &field : fields) {
|
||||||
|
createTableSQL += field + ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the last comma and space
|
||||||
|
createTableSQL.chop(2);
|
||||||
|
|
||||||
|
createTableSQL += ")";
|
||||||
|
|
||||||
|
QSqlQuery query;
|
||||||
|
bool res = query.exec();
|
||||||
|
if (!res) {
|
||||||
|
qDebug() << "Error creating dynamic table:" << query.lastError().text();
|
||||||
|
} else {
|
||||||
|
qDebug() << "Dynamic table created successfully!";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ class DesignerScene;
|
||||||
class DiagramCavas;
|
class DiagramCavas;
|
||||||
class ElectricElementsBox;
|
class ElectricElementsBox;
|
||||||
class LoadPageDlg;
|
class LoadPageDlg;
|
||||||
|
class projectModelDlg;
|
||||||
|
|
||||||
class CMainWindow : public QMainWindow
|
class CMainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
|
|
@ -41,6 +42,7 @@ private slots:
|
||||||
void onAction_zoomFit();
|
void onAction_zoomFit();
|
||||||
void onAction_createGroup();
|
void onAction_createGroup();
|
||||||
void onAction_destroyGroup();
|
void onAction_destroyGroup();
|
||||||
|
void onAction_editProject();
|
||||||
void onSignal_addItem(QGraphicsItem*);
|
void onSignal_addItem(QGraphicsItem*);
|
||||||
void onSignal_deleteItem();
|
void onSignal_deleteItem();
|
||||||
void onSignal_loadPage();
|
void onSignal_loadPage();
|
||||||
|
|
@ -66,5 +68,6 @@ private:
|
||||||
ElectricElementsBox* m_pElectricElementsBox;
|
ElectricElementsBox* m_pElectricElementsBox;
|
||||||
GraphicElementsPanel* m_pGraphicElementsPanel;
|
GraphicElementsPanel* m_pGraphicElementsPanel;
|
||||||
LoadPageDlg* m_pLoadPageDlg;
|
LoadPageDlg* m_pLoadPageDlg;
|
||||||
|
projectModelDlg* m_pProjectModelDlg;
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
#ifndef PROJECTMODELDLG_H
|
||||||
|
#define PROJECTMODELDLG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
#include <QItemSelection>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
namespace Ui { class projectModelDlg; }
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
struct PropertyPage //属性列表信息
|
||||||
|
{
|
||||||
|
QStandardItemModel* pBase; //基础属性
|
||||||
|
QStandardItemModel* pSelect; //已选择属性
|
||||||
|
QMap<QString,bool> mCheckState; //属性选择状态
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QMap<QString,PropertyPage> MapProperty; //str为属性名,model1基础属性,model2已选择属性
|
||||||
|
struct PropertyModel //工程模
|
||||||
|
{
|
||||||
|
MapProperty mapProperty;
|
||||||
|
int nType; //工程模类型,选择图标后确定
|
||||||
|
};
|
||||||
|
typedef QMap<QString,PropertyModel> MapProject; //str为工程名,property为属性集
|
||||||
|
typedef QMap<QString,MapProject> MapMeta; //str为元模名,project为工程模集
|
||||||
|
|
||||||
|
class RenameModel;
|
||||||
|
|
||||||
|
class projectModelDlg : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
projectModelDlg(QWidget *parent = nullptr);
|
||||||
|
~projectModelDlg();
|
||||||
|
|
||||||
|
void initial();
|
||||||
|
void initialModel();
|
||||||
|
void initialList();
|
||||||
|
MapProperty addNewProject(const QString& sMeta,const QString& sProject); //根据元模型、工程模名称生成工程模对象
|
||||||
|
void update();
|
||||||
|
void generate(const QString&); //根据输入名称生成表
|
||||||
|
|
||||||
|
QString getProjectName() const; //返回当前选择项目的名称
|
||||||
|
public slots:
|
||||||
|
void onSaveClicked();
|
||||||
|
void onCancelClicked();
|
||||||
|
void onGenerateClicked();
|
||||||
|
void onApplyClicked();
|
||||||
|
void onRevokeClicked();
|
||||||
|
void onBaseModelIndexChanged(const QString&);
|
||||||
|
void onProjectIndexChanged(const QString&);
|
||||||
|
void onPropertyIndexChanged(const QString&);
|
||||||
|
void onIconClicked(const QModelIndex &index); //关联图元改变
|
||||||
|
public:
|
||||||
|
QStringList getModelList() const; //获取元模型列表
|
||||||
|
QStringList getGroupList(const QString& model) const; //返回该元模下的属性组列表
|
||||||
|
QStringList getAttributeList(const QString& model,const QString& group) const; //根据元模名和组名返回属性列表
|
||||||
|
void setItemAttribute(const QString&,QStandardItem*); //设置item的属性(数据库表字段名)
|
||||||
|
QString combinePropertySql(const QStandardItem*); //根据item属性生成sql
|
||||||
|
private:
|
||||||
|
void updateIconList(); //选择工程模后刷新关联图标
|
||||||
|
private:
|
||||||
|
Ui::projectModelDlg *ui;
|
||||||
|
RenameModel* m_pRenameModel;
|
||||||
|
QStandardItemModel* _viewModel; //索引view模型
|
||||||
|
MapMeta m_mapTotal;
|
||||||
|
QString _curMeta; //当前元模型
|
||||||
|
QString _curProject; //当前工程模
|
||||||
|
QString _curProperty; //当前属性
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
#ifndef RENAMEMODEL_H
|
||||||
|
#define RENAMEMODEL_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
namespace Ui { class renameModel; }
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class projectModelDlg;
|
||||||
|
|
||||||
|
class RenameModel : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
RenameModel(QWidget *parent = nullptr);
|
||||||
|
~RenameModel();
|
||||||
|
|
||||||
|
void initial();
|
||||||
|
void showCenter();
|
||||||
|
signals:
|
||||||
|
void selectedPage(const QString&);
|
||||||
|
public slots:
|
||||||
|
void onOkClicked();
|
||||||
|
void onCancelClicked();
|
||||||
|
private:
|
||||||
|
void setShowName(); //获取当前名称并显示
|
||||||
|
bool couldSave(); //判断当前名称是否可用
|
||||||
|
private:
|
||||||
|
Ui::renameModel *ui;
|
||||||
|
projectModelDlg* _pParent;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include "electricElementsPanel.h"
|
#include "electricElementsPanel.h"
|
||||||
#include "toolBox.h"
|
#include "toolBox.h"
|
||||||
#include "loadPageDlg.h"
|
#include "loadPageDlg.h"
|
||||||
|
#include "projectModelDlg.h"
|
||||||
|
|
||||||
//using namespace ads;
|
//using namespace ads;
|
||||||
|
|
||||||
|
|
@ -62,13 +63,6 @@ void CMainWindow::changeEvent(QEvent* event)
|
||||||
|
|
||||||
void CMainWindow::initializeDockUi()
|
void CMainWindow::initializeDockUi()
|
||||||
{
|
{
|
||||||
/*ElectricElementsPanel* pPanel1 = new ElectricElementsPanel();
|
|
||||||
QMap<QString,GraphicsItemType> map1;
|
|
||||||
map1.insert(QString::fromWCharArray(L"三角"),GIT_rect);
|
|
||||||
map1.insert(QString::fromWCharArray(L"四边"),GIT_rect);
|
|
||||||
pPanel1->setData(map1);
|
|
||||||
pPanel1->show();*/
|
|
||||||
|
|
||||||
m_pElectricElementsBox = new ElectricElementsBox();
|
m_pElectricElementsBox = new ElectricElementsBox();
|
||||||
m_pElectricElementsBox->initial();
|
m_pElectricElementsBox->initial();
|
||||||
QWidget* pBox = m_pElectricElementsBox->getToolBox();
|
QWidget* pBox = m_pElectricElementsBox->getToolBox();
|
||||||
|
|
@ -83,17 +77,7 @@ void CMainWindow::initializeDockUi()
|
||||||
this->setCentralWidget(m_pDiagramCavas);
|
this->setCentralWidget(m_pDiagramCavas);
|
||||||
connect(m_pElectricElementsBox,&ElectricElementsBox::addEletricItem,m_pDiagramCavas,&DiagramCavas::onSignal_addGraphicsItem);
|
connect(m_pElectricElementsBox,&ElectricElementsBox::addEletricItem,m_pDiagramCavas,&DiagramCavas::onSignal_addGraphicsItem);
|
||||||
|
|
||||||
/*QTableWidget* propertiesTable = new QTableWidget();
|
m_pProjectModelDlg = new projectModelDlg(this);
|
||||||
propertiesTable->setColumnCount(3);
|
|
||||||
propertiesTable->setRowCount(10);
|
|
||||||
CDockWidget* PropertiesDockWidget = new CDockWidget(QString::fromWCharArray(L"属性编辑器"));
|
|
||||||
PropertiesDockWidget->setWidget(propertiesTable);
|
|
||||||
PropertiesDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
|
||||||
PropertiesDockWidget->resize(250, 150);
|
|
||||||
PropertiesDockWidget->setMinimumSize(200,150);
|
|
||||||
DockManager->addDockWidget(DockWidgetArea::RightDockWidgetArea, PropertiesDockWidget, CentralDockArea);
|
|
||||||
ui->menuView->addAction(PropertiesDockWidget->toggleViewAction());*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::initializeAction()
|
void CMainWindow::initializeAction()
|
||||||
|
|
@ -127,6 +111,9 @@ void CMainWindow::initializeAction()
|
||||||
|
|
||||||
QAction* actRun = ui->menuMode->addAction(QString::fromWCharArray(L"运行"));
|
QAction* actRun = ui->menuMode->addAction(QString::fromWCharArray(L"运行"));
|
||||||
connect(actRun,&QAction::triggered,m_pDiagramCavas,&DiagramCavas::onSignal_runPage);
|
connect(actRun,&QAction::triggered,m_pDiagramCavas,&DiagramCavas::onSignal_runPage);
|
||||||
|
|
||||||
|
QAction* actEdit = ui->menuProject->addAction(QString::fromWCharArray(L"编辑工程模"));
|
||||||
|
connect(actEdit,&QAction::triggered,this,&CMainWindow::onAction_editProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::onAction_zoomIn()
|
void CMainWindow::onAction_zoomIn()
|
||||||
|
|
@ -174,6 +161,12 @@ void CMainWindow::onAction_destroyGroup()
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMainWindow::onAction_editProject()
|
||||||
|
{
|
||||||
|
if(m_pProjectModelDlg)
|
||||||
|
m_pProjectModelDlg->show();
|
||||||
|
}
|
||||||
|
|
||||||
void CMainWindow::onSignal_addItem(QGraphicsItem* item)
|
void CMainWindow::onSignal_addItem(QGraphicsItem* item)
|
||||||
{
|
{
|
||||||
if(item)
|
if(item)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,667 @@
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include "projectModelDlg.h"
|
||||||
|
#include "renameModel.h"
|
||||||
|
#include "dataBase.h"
|
||||||
|
#include "ui_projectModelDlg.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
const QSet<QString> stringDataTypes = {"varchar", "char", "text", "date", "time", "timestamp"};
|
||||||
|
|
||||||
|
projectModelDlg::projectModelDlg(QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
, ui(new Ui::projectModelDlg)
|
||||||
|
,m_pRenameModel(nullptr)
|
||||||
|
,_viewModel(nullptr)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||||
|
setWindowModality(Qt::WindowModal);
|
||||||
|
m_pRenameModel = new RenameModel(this);
|
||||||
|
if(m_pRenameModel)
|
||||||
|
m_pRenameModel->hide();
|
||||||
|
initial();
|
||||||
|
}
|
||||||
|
|
||||||
|
projectModelDlg::~projectModelDlg()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::initial()
|
||||||
|
{
|
||||||
|
connect(ui->btn_generate,&QPushButton::clicked,this,&projectModelDlg::onGenerateClicked);
|
||||||
|
connect(ui->btn_save,&QPushButton::clicked,this,&projectModelDlg::onSaveClicked);
|
||||||
|
connect(ui->btn_cancel,&QPushButton::clicked,this,&projectModelDlg::onCancelClicked);
|
||||||
|
connect(ui->btn_apply,&QPushButton::clicked,this,&projectModelDlg::onApplyClicked);
|
||||||
|
connect(ui->btn_revoke,&QPushButton::clicked,this,&projectModelDlg::onRevokeClicked);
|
||||||
|
|
||||||
|
connect(ui->cb_baseModel,&QComboBox::textActivated,this,&projectModelDlg::onBaseModelIndexChanged);
|
||||||
|
connect(ui->cb_projectModel,&QComboBox::textActivated,this,&projectModelDlg::onProjectIndexChanged);
|
||||||
|
connect(ui->cb_property,&QComboBox::textActivated,this,&projectModelDlg::onPropertyIndexChanged);
|
||||||
|
|
||||||
|
initialModel();
|
||||||
|
initialList();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
MapProperty projectModelDlg::addNewProject(const QString& sMeta,const QString& sProject) //todo:保存后生成新建
|
||||||
|
{
|
||||||
|
MapProperty mt;
|
||||||
|
QStringList lstProperty = getGroupList(sMeta);
|
||||||
|
//lstProperty<<QString("base")<<QString("seperation");
|
||||||
|
|
||||||
|
QMap<QString,QJsonObject> mapCheckState = DataBase::GetInstance()->getCheckStateFromManager(sProject); //获取选择状态
|
||||||
|
if(mapCheckState.isEmpty()) //无返回值,是新建目标
|
||||||
|
{
|
||||||
|
for(auto &property:lstProperty)
|
||||||
|
{
|
||||||
|
//todo:读取属性信息
|
||||||
|
QStringList lstName = getAttributeList(sMeta,property);
|
||||||
|
//lstName<<QString("apple")<<QString("banana")<<QString("orange");
|
||||||
|
|
||||||
|
PropertyPage struProperty;
|
||||||
|
struProperty.pBase = new QStandardItemModel(this);
|
||||||
|
struProperty.pSelect = new QStandardItemModel(this);
|
||||||
|
//propertyItem->appendRow(new QStandardItem(property)); //总览view
|
||||||
|
|
||||||
|
for(auto &name:lstName)
|
||||||
|
{
|
||||||
|
QStandardItem* pItem = new QStandardItem(name);
|
||||||
|
setItemAttribute(name,pItem);
|
||||||
|
struProperty.pBase->appendRow(pItem);
|
||||||
|
struProperty.mCheckState.insert(name,0); //初始都是未选择状态
|
||||||
|
}
|
||||||
|
mt.insert(property,struProperty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(auto &property:lstProperty)
|
||||||
|
{
|
||||||
|
QJsonObject obj = mapCheckState[property];
|
||||||
|
QJsonArray nodesJsonArray = obj["checkState"].toArray();
|
||||||
|
|
||||||
|
PropertyPage struProperty;
|
||||||
|
struProperty.pBase = new QStandardItemModel(this);
|
||||||
|
struProperty.pSelect = new QStandardItemModel(this);
|
||||||
|
for (QJsonValueRef nodeJson : nodesJsonArray)
|
||||||
|
{
|
||||||
|
QJsonObject node = nodeJson.toObject();
|
||||||
|
QString propertyName = node["name"].toString();
|
||||||
|
int nState = node["checked"].toInt();
|
||||||
|
|
||||||
|
QStandardItem* pItem = new QStandardItem(propertyName);
|
||||||
|
setItemAttribute(propertyName,pItem);
|
||||||
|
if(nState)
|
||||||
|
{
|
||||||
|
struProperty.pSelect->appendRow(pItem);
|
||||||
|
struProperty.mCheckState.insert(propertyName,1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struProperty.pBase->appendRow(pItem);
|
||||||
|
struProperty.mCheckState.insert(propertyName,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mt.insert(property,struProperty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::initialModel()
|
||||||
|
{
|
||||||
|
_viewModel = new QStandardItemModel(this);
|
||||||
|
QStringList lstModel = getModelList();
|
||||||
|
//lstType<<QString("metaModel1")<<QString("metaModel2");
|
||||||
|
for(auto &model:lstModel)
|
||||||
|
{
|
||||||
|
MapProject mp;
|
||||||
|
QStringList lstProject;
|
||||||
|
lstProject<<QString::fromWCharArray(L"新建"); //每个类别都有未命名工程
|
||||||
|
QStandardItem* modelItem = new QStandardItem(model); //总览view类型
|
||||||
|
|
||||||
|
for(auto &proj:lstProject)
|
||||||
|
{
|
||||||
|
QStandardItem* propertyItem = new QStandardItem(proj);
|
||||||
|
modelItem->appendRow(propertyItem); //总览view名称
|
||||||
|
|
||||||
|
PropertyModel pm;
|
||||||
|
pm.mapProperty = addNewProject(model,proj);
|
||||||
|
mp.insert(proj,pm);
|
||||||
|
}
|
||||||
|
_viewModel->appendRow(modelItem);
|
||||||
|
//todo:读取存储,按分类遍历名称
|
||||||
|
m_mapTotal.insert(model,mp);
|
||||||
|
}
|
||||||
|
ui->treeView_model->setModel(_viewModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::initialList()
|
||||||
|
{
|
||||||
|
QStandardItemModel *model = new QStandardItemModel(this);
|
||||||
|
ui->listView_icon->setModel(model);
|
||||||
|
|
||||||
|
QStandardItem* pNon = new QStandardItem(QString::fromWCharArray(L"未选择"));
|
||||||
|
QStandardItem* pMotor = new QStandardItem("motor");
|
||||||
|
QStandardItem* pBus = new QStandardItem("bus");
|
||||||
|
pNon->setData(0,Qt::UserRole);
|
||||||
|
pMotor->setData(1,Qt::UserRole);
|
||||||
|
pBus->setData(2,Qt::UserRole);
|
||||||
|
model->appendRow(pNon);
|
||||||
|
model->appendRow(pMotor);
|
||||||
|
model->appendRow(pBus);
|
||||||
|
|
||||||
|
connect(ui->listView_icon,&QListView::clicked,this,&projectModelDlg::onIconClicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::update()
|
||||||
|
{
|
||||||
|
for(MapMeta::Iterator iter = m_mapTotal.begin();iter != m_mapTotal.end();++iter)
|
||||||
|
{
|
||||||
|
ui->cb_baseModel->addItem(iter.key());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::generate(const QString& str)
|
||||||
|
{
|
||||||
|
QString pre = QString("project_");
|
||||||
|
MapMeta::Iterator iter = m_mapTotal.find(_curMeta); //获取元模下的工程
|
||||||
|
if(iter != m_mapTotal.end())
|
||||||
|
{
|
||||||
|
MapProject mp = iter.value();
|
||||||
|
MapProject::Iterator ite = mp.find(_curProject); //获取工程下的属性组
|
||||||
|
if(ite != mp.end())
|
||||||
|
{
|
||||||
|
MapProperty mapProperty = ite.value().mapProperty;
|
||||||
|
|
||||||
|
bool createRes = true; //动态表生成结果
|
||||||
|
for(MapProperty::Iterator it = mapProperty.begin();it != mapProperty.end();++it){ //每个属性组单独生成表
|
||||||
|
QUuid uuid = QUuid::createUuid();
|
||||||
|
// 不带花括号的 UUID 字符串
|
||||||
|
QString noDashes = uuid.toString(QUuid::WithoutBraces);
|
||||||
|
QString uuidString = noDashes.replace("-", "");
|
||||||
|
QString sName = pre+it.key()+QString("_")+uuidString; //生成表名
|
||||||
|
|
||||||
|
QStringList fields;
|
||||||
|
fields.append("id SERIAL NOT NULL PRIMARY KEY");
|
||||||
|
fields.append("global_uuid uuid NOT NULL DEFAULT gen_random_uuid()");
|
||||||
|
fields.append("attribute_group VARCHAR(64) NOT NULL");
|
||||||
|
|
||||||
|
QJsonObject objState;
|
||||||
|
QJsonArray arrState;
|
||||||
|
|
||||||
|
QStandardItemModel* pSelectModel = it->pSelect;
|
||||||
|
QStandardItem *rootItem = pSelectModel->invisibleRootItem();
|
||||||
|
for (int row = 0; row < rootItem->rowCount(); ++row) { //遍历已选择列表
|
||||||
|
QStandardItem *childItem = rootItem->child(row);
|
||||||
|
if (childItem) {
|
||||||
|
QString s = combinePropertySql(childItem); //拼接单句sql
|
||||||
|
fields.append(s);
|
||||||
|
|
||||||
|
QJsonObject node; //保存已选择状态
|
||||||
|
node["name"] = rootItem->text();
|
||||||
|
node["checked"] = 1;
|
||||||
|
arrState.append(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QStandardItemModel* pBaseModel = it->pBase;
|
||||||
|
rootItem = pBaseModel->invisibleRootItem();
|
||||||
|
for (int row = 0; row < rootItem->rowCount(); ++row) { //遍历未选择列表
|
||||||
|
QStandardItem *childItem = rootItem->child(row);
|
||||||
|
if (childItem) {
|
||||||
|
QJsonObject node; //保存未选择状态
|
||||||
|
node["name"] = rootItem->text();
|
||||||
|
node["checked"] = 0;
|
||||||
|
arrState.append(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!DataBase::GetInstance()->createDynamicTable(sName,fields))
|
||||||
|
{
|
||||||
|
createRes = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objState["checkState"] = arrState;
|
||||||
|
DataBase::GetInstance()->insertProjectManager(sName,str,_curMeta,it.key(),ite.value().nType,objState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(createRes)
|
||||||
|
{
|
||||||
|
PropertyModel pm = m_mapTotal[_curMeta].take(_curProject); //取出要保存的对象,另存为新索引
|
||||||
|
m_mapTotal[_curMeta].insert(str,pm);
|
||||||
|
|
||||||
|
if(_curProject == QString::fromWCharArray(L"新建"))
|
||||||
|
{
|
||||||
|
ui->cb_projectModel->addItem(str);
|
||||||
|
addNewProject(_curMeta,_curProject);
|
||||||
|
QList<QStandardItem*> lst = _viewModel->findItems(_curMeta);
|
||||||
|
if(lst.size() == 1)
|
||||||
|
{
|
||||||
|
QStandardItem* item = lst[0];
|
||||||
|
item->appendRow(new QStandardItem(str));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_curProject = str;
|
||||||
|
|
||||||
|
}
|
||||||
|
else //创建失败
|
||||||
|
{
|
||||||
|
QMessageBox::information(NULL, QString::fromWCharArray(L"提示"), QString::fromWCharArray(L"创建表失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString projectModelDlg::getProjectName() const
|
||||||
|
{
|
||||||
|
return _curProject;
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::onSaveClicked()
|
||||||
|
{
|
||||||
|
if(_curProject.isEmpty())
|
||||||
|
{
|
||||||
|
QMessageBox::information(NULL, QString::fromWCharArray(L"提示"), QString::fromWCharArray(L"请选择操作的工程对象"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(_curProject == QString::fromWCharArray(L"新建"))
|
||||||
|
{
|
||||||
|
if(m_pRenameModel)
|
||||||
|
{
|
||||||
|
m_pRenameModel->showCenter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::onGenerateClicked()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::onCancelClicked()
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::onApplyClicked()
|
||||||
|
{
|
||||||
|
if(_curProperty.isEmpty())
|
||||||
|
{
|
||||||
|
QMessageBox::information(NULL, QString::fromWCharArray(L"提示"), QString::fromWCharArray(L"请先选择属性"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MapMeta::Iterator iter = m_mapTotal.find(_curMeta);
|
||||||
|
if(iter != m_mapTotal.end())
|
||||||
|
{
|
||||||
|
MapProject project = iter.value();
|
||||||
|
MapProject::Iterator it= project.find(_curProject);
|
||||||
|
if(it != project.end())
|
||||||
|
{
|
||||||
|
MapProperty property = it.value().mapProperty;
|
||||||
|
QModelIndex selected = ui->treeView_base->currentIndex();
|
||||||
|
QStandardItem* item = property[_curProperty].pBase->takeItem(selected.row());
|
||||||
|
if(item)
|
||||||
|
{
|
||||||
|
property[_curProperty].pSelect->appendRow(item);
|
||||||
|
property[_curProperty].pBase->removeRow(selected.row());
|
||||||
|
property[_curProperty].mCheckState[item->text()] = 1; //选择状态设为1
|
||||||
|
}
|
||||||
|
/*MapProperty::Iterator ite = property.find(_curProperty);
|
||||||
|
if(ite != property.end())
|
||||||
|
{
|
||||||
|
QStandardItemModel* pBase = ite.value().pBase;
|
||||||
|
QStandardItemModel* pSelect = ite.value().pSelect;
|
||||||
|
|
||||||
|
QModelIndex selected = ui->treeView_base->currentIndex();
|
||||||
|
QStandardItem* item = pBase->takeItem(selected.row()); // 根据index获取当前item
|
||||||
|
if(item)
|
||||||
|
{
|
||||||
|
pSelect->appendRow(item);
|
||||||
|
pBase->removeRow(selected.row());
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::onRevokeClicked()
|
||||||
|
{
|
||||||
|
if(_curProperty.isEmpty())
|
||||||
|
{
|
||||||
|
QMessageBox::information(NULL, QString::fromWCharArray(L"提示"), QString::fromWCharArray(L"请先选择属性"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MapMeta::Iterator iter = m_mapTotal.find(_curMeta);
|
||||||
|
if(iter != m_mapTotal.end())
|
||||||
|
{
|
||||||
|
MapProject project = iter.value();
|
||||||
|
MapProject::Iterator it= project.find(_curProject);
|
||||||
|
if(it != project.end())
|
||||||
|
{
|
||||||
|
MapProperty property = it.value().mapProperty;
|
||||||
|
QModelIndex selected = ui->treeView_sub->currentIndex();
|
||||||
|
QStandardItem* item = property[_curProperty].pSelect->takeItem(selected.row());
|
||||||
|
if(item)
|
||||||
|
{
|
||||||
|
property[_curProperty].pBase->appendRow(item);
|
||||||
|
property[_curProperty].pSelect->removeRow(selected.row());
|
||||||
|
property[_curProperty].mCheckState[item->text()] = 0; //选择状态设为0
|
||||||
|
}
|
||||||
|
/*MapProperty::Iterator ite = property.find(_curProperty);
|
||||||
|
if(ite != property.end())
|
||||||
|
{
|
||||||
|
QStandardItemModel* pBase = ite.value().pBase;
|
||||||
|
QStandardItemModel* pSelect = ite.value().pSelect;
|
||||||
|
|
||||||
|
QModelIndex selected = ui->treeView_sub->currentIndex();
|
||||||
|
QStandardItem* item = pSelect->takeItem(selected.row()); // 根据index获取当前item
|
||||||
|
if(item)
|
||||||
|
{
|
||||||
|
pBase->appendRow(item);
|
||||||
|
pSelect->removeRow(selected.row());
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::onBaseModelIndexChanged(const QString& str)
|
||||||
|
{
|
||||||
|
if(_curMeta == str) //选择未改变
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ui->stackedWidget->currentIndex() !=1) //选择元模时隐藏iconlist
|
||||||
|
{
|
||||||
|
ui->stackedWidget->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
ui->treeView_base->setModel(nullptr);
|
||||||
|
ui->treeView_sub->setModel(nullptr);
|
||||||
|
MapMeta::Iterator iter = m_mapTotal.find(str);
|
||||||
|
if(iter != m_mapTotal.end())
|
||||||
|
{
|
||||||
|
//先清空已有
|
||||||
|
_curMeta = str;
|
||||||
|
_curProject = "";
|
||||||
|
_curProperty = "";
|
||||||
|
ui->cb_projectModel->clear();
|
||||||
|
ui->cb_property->clear();
|
||||||
|
MapProject project = iter.value();
|
||||||
|
for(MapProject::Iterator it = project.begin();it != project.end();++it)
|
||||||
|
{
|
||||||
|
ui->cb_projectModel->addItem(it.key());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::onProjectIndexChanged(const QString& str)
|
||||||
|
{
|
||||||
|
if(_curMeta.isEmpty())
|
||||||
|
{
|
||||||
|
QMessageBox::information(NULL, QString::fromWCharArray(L"提示"), QString::fromWCharArray(L"请先选择元模型"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
updateIconList();
|
||||||
|
if(_curProject == str) //选择未改变
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ui->treeView_base->setModel(nullptr);
|
||||||
|
ui->treeView_sub->setModel(nullptr);
|
||||||
|
MapMeta::Iterator iter = m_mapTotal.find(_curMeta);
|
||||||
|
if(iter != m_mapTotal.end())
|
||||||
|
{
|
||||||
|
MapProject project = iter.value();
|
||||||
|
MapProject::Iterator it= project.find(str);
|
||||||
|
if(it != project.end())
|
||||||
|
{
|
||||||
|
_curProject = str;
|
||||||
|
_curProperty = "";
|
||||||
|
ui->cb_property->clear();
|
||||||
|
MapProperty property = it.value().mapProperty;
|
||||||
|
for(MapProperty::Iterator ite = property.begin();ite != property.end();++ite)
|
||||||
|
{
|
||||||
|
ui->cb_property->addItem(ite.key());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::onPropertyIndexChanged(const QString& str)
|
||||||
|
{
|
||||||
|
if(_curProject.isEmpty())
|
||||||
|
{
|
||||||
|
QMessageBox::information(NULL, QString::fromWCharArray(L"提示"), QString::fromWCharArray(L"请先选择工程模型"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(_curProperty == str)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ui->treeView_base->setModel(nullptr);
|
||||||
|
ui->treeView_sub->setModel(nullptr);
|
||||||
|
MapMeta::Iterator iter = m_mapTotal.find(_curMeta);
|
||||||
|
if(iter != m_mapTotal.end())
|
||||||
|
{
|
||||||
|
MapProject project = iter.value();
|
||||||
|
MapProject::Iterator it= project.find(_curProject);
|
||||||
|
if(it != project.end())
|
||||||
|
{
|
||||||
|
MapProperty property = it.value().mapProperty;
|
||||||
|
MapProperty::Iterator ite = property.find(str);
|
||||||
|
if(ite != property.end())
|
||||||
|
{
|
||||||
|
_curProperty = str;
|
||||||
|
ui->treeView_base->setModel(nullptr);
|
||||||
|
ui->treeView_sub->setModel(nullptr);
|
||||||
|
QStandardItemModel* pBase = ite.value().pBase;
|
||||||
|
QStandardItemModel* pSelect = ite.value().pSelect;
|
||||||
|
ui->treeView_base->setModel(pBase);
|
||||||
|
ui->treeView_sub->setModel(pSelect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::onIconClicked(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
QStandardItemModel *model = dynamic_cast<QStandardItemModel*>(ui->listView_icon->model());
|
||||||
|
if(model)
|
||||||
|
{
|
||||||
|
QStandardItem* pItem = model->itemFromIndex(index);
|
||||||
|
int id = pItem->data(Qt::UserRole).toInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
QStringList projectModelDlg::getModelList() const
|
||||||
|
{
|
||||||
|
QMap<int,modelAttribute> modelMap = DataBase::GetInstance()->ModelAttribute();
|
||||||
|
|
||||||
|
QSet<QString> modelSet;
|
||||||
|
for(auto &model:modelMap)
|
||||||
|
{
|
||||||
|
modelSet.insert(model.modelType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return QStringList(modelSet.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList projectModelDlg::getGroupList(const QString& sM) const
|
||||||
|
{
|
||||||
|
QMap<int,attributeGroup> groupMap = DataBase::GetInstance()->AttributeGroup();
|
||||||
|
QMap<int,modelAttribute> modelMap = DataBase::GetInstance()->ModelAttribute();
|
||||||
|
QMap<int,attribute> attMap = DataBase::GetInstance()->Attribute();
|
||||||
|
|
||||||
|
QSet<int> groupSet;
|
||||||
|
QStringList groupList;
|
||||||
|
for(auto &model:modelMap) //遍历获取属性组id
|
||||||
|
{
|
||||||
|
if(model.modelType == sM)
|
||||||
|
{
|
||||||
|
int attId = model.attributeId;
|
||||||
|
groupSet.insert(attMap[attId].attributeGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto &id:groupSet) //取得id对应的组名
|
||||||
|
{
|
||||||
|
groupList.append(groupMap[id].group);
|
||||||
|
}
|
||||||
|
return groupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList projectModelDlg::getAttributeList(const QString& sM,const QString& sG) const
|
||||||
|
{
|
||||||
|
QMap<int,attributeGroup> groupMap = DataBase::GetInstance()->AttributeGroup();
|
||||||
|
QMap<int,modelAttribute> modelMap = DataBase::GetInstance()->ModelAttribute();
|
||||||
|
QMap<int,attribute> attMap = DataBase::GetInstance()->Attribute();
|
||||||
|
|
||||||
|
int groupId = -1;
|
||||||
|
for(auto &group:groupMap)
|
||||||
|
{
|
||||||
|
if(group.group == sG) //根据group获取对应Id
|
||||||
|
{
|
||||||
|
groupId = group.id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QSet<int> attSet;
|
||||||
|
QStringList attList;
|
||||||
|
if(groupId != -1)
|
||||||
|
{
|
||||||
|
for(auto &model:modelMap) //获取当前模型,当前属性组下的属性
|
||||||
|
{
|
||||||
|
if(model.modelType == sM)
|
||||||
|
{
|
||||||
|
int attId = model.attributeId;
|
||||||
|
if(attMap[attId].attributeGroup == groupId) //当前属性的属性组id等于选定的属性组id
|
||||||
|
{
|
||||||
|
attSet.insert(model.attributeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto &id:attSet) //取得id对应的组名
|
||||||
|
{
|
||||||
|
attList.append(attMap[id].attribute);
|
||||||
|
}
|
||||||
|
return attList;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::setItemAttribute(const QString& name,QStandardItem* p)
|
||||||
|
{
|
||||||
|
QMap<int,attribute> attMap = DataBase::GetInstance()->Attribute();
|
||||||
|
|
||||||
|
for(auto &att:attMap)
|
||||||
|
{
|
||||||
|
if(name == att.attribute)
|
||||||
|
{
|
||||||
|
p->setData(att.id,Id);
|
||||||
|
p->setData(att.attribute,Attribute);
|
||||||
|
p->setData(att.dataType,DataType);
|
||||||
|
p->setData(att.lengthPrecision,LengthPrecision);
|
||||||
|
p->setData(att.scale,Scale);
|
||||||
|
p->setData(att.defaultValue,DefaultValue);
|
||||||
|
p->setData(att.valueRange,ValueRange);
|
||||||
|
p->setData(att.attributeGroup,AttributeGroup);
|
||||||
|
p->setData(att.isNotNull,IsNotNull);
|
||||||
|
p->setData(att.isPrimaryKey,IsPrimaryKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString projectModelDlg::combinePropertySql(const QStandardItem* pItem)
|
||||||
|
{
|
||||||
|
int id = pItem->data(Id).toInt();
|
||||||
|
QString attribute = pItem->data(Attribute).toString();
|
||||||
|
QString dataType = pItem->data(DataType).toString();
|
||||||
|
int lengthPrecision = pItem->data(LengthPrecision).toInt();
|
||||||
|
int scale = pItem->data(Scale).toInt();
|
||||||
|
QString defaultValue = pItem->data(DefaultValue).toString();
|
||||||
|
QString valueRange = pItem->data(ValueRange).toString();
|
||||||
|
int attributeGroup = pItem->data(AttributeGroup).toInt();
|
||||||
|
int isNotNull = pItem->data(IsNotNull).toInt();
|
||||||
|
int isPrimaryKey = pItem->data(IsPrimaryKey).toInt();
|
||||||
|
|
||||||
|
bool needsQuotes = stringDataTypes.contains(dataType);
|
||||||
|
// 处理数据类型及其长度精度
|
||||||
|
QString dataTypePart = dataType;
|
||||||
|
if (lengthPrecision > 0) {
|
||||||
|
dataTypePart += QString("(%1").arg(lengthPrecision);
|
||||||
|
if (scale > 0) {
|
||||||
|
dataTypePart += QString(",%1").arg(scale);
|
||||||
|
}
|
||||||
|
dataTypePart += ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始拼接SQL
|
||||||
|
QString sql = QString("%1 %2").arg(attribute, dataTypePart);
|
||||||
|
|
||||||
|
// 处理约束条件
|
||||||
|
if (isNotNull != 0) {
|
||||||
|
sql += " NOT NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!defaultValue.isEmpty()) {
|
||||||
|
QString defValue = defaultValue;
|
||||||
|
if (needsQuotes) {
|
||||||
|
// 转义单引号并包裹
|
||||||
|
defValue.replace("'", "''");
|
||||||
|
defValue = QString("'%1'").arg(defValue);
|
||||||
|
}
|
||||||
|
sql += QString(" DEFAULT %1").arg(defValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPrimaryKey != 0) {
|
||||||
|
sql += " PRIMARY KEY";
|
||||||
|
}
|
||||||
|
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectModelDlg::updateIconList()
|
||||||
|
{
|
||||||
|
if(ui->stackedWidget->currentIndex() !=0)
|
||||||
|
{
|
||||||
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
MapProject mp = m_mapTotal[_curMeta];
|
||||||
|
int nType = mp[_curProject].nType;
|
||||||
|
QStandardItemModel *model = dynamic_cast<QStandardItemModel*>(ui->listView_icon->model());
|
||||||
|
if(model)
|
||||||
|
{
|
||||||
|
for (int row = 0; row < model->rowCount(); ++row)
|
||||||
|
{
|
||||||
|
QStandardItem* pItem = model->item(row);
|
||||||
|
int id = pItem->data(Qt::UserRole).toInt();
|
||||||
|
if(nType == id) //使用存储的序列号更新list
|
||||||
|
{
|
||||||
|
QModelIndex index = model->index(id,0);
|
||||||
|
ui->listView_icon->setCurrentIndex(index);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,105 @@
|
||||||
|
#include "renameModel.h"
|
||||||
|
#include "projectModelDlg.h"
|
||||||
|
#include "ui_renameModel.h"
|
||||||
|
|
||||||
|
RenameModel::RenameModel(QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
, ui(new Ui::renameModel)
|
||||||
|
,_pParent(nullptr)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||||
|
_pParent = dynamic_cast<projectModelDlg*>(parent);
|
||||||
|
initial();
|
||||||
|
}
|
||||||
|
|
||||||
|
RenameModel::~RenameModel()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenameModel::initial()
|
||||||
|
{
|
||||||
|
connect(ui->btn_ok,&QPushButton::clicked,this,&RenameModel::onOkClicked);
|
||||||
|
connect(ui->btn_cancel,&QPushButton::clicked,this,&RenameModel::onCancelClicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenameModel::showCenter()
|
||||||
|
{
|
||||||
|
if (!_pParent) {
|
||||||
|
qWarning("No parent widget found; dialog will appear at the default position.");
|
||||||
|
show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 父窗口的几何信息
|
||||||
|
QRect parentRect = _pParent->geometry();
|
||||||
|
|
||||||
|
// 对话框的几何信息
|
||||||
|
int dialogWidth = width();
|
||||||
|
int dialogHeight = height();
|
||||||
|
|
||||||
|
// 计算中心位置
|
||||||
|
int x = parentRect.x() + (parentRect.width() - dialogWidth) / 2;
|
||||||
|
int y = parentRect.y() + (parentRect.height() - dialogHeight) / 2;
|
||||||
|
|
||||||
|
// 移动对话框到中心位置并显示
|
||||||
|
move(x, y);
|
||||||
|
show();
|
||||||
|
|
||||||
|
setShowName();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenameModel::setShowName()
|
||||||
|
{
|
||||||
|
if(_pParent)
|
||||||
|
{
|
||||||
|
QString str = _pParent->getProjectName();
|
||||||
|
ui->lineEdit_name->setText(str);
|
||||||
|
|
||||||
|
ui->lineEdit_name->setSelection(0,str.length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RenameModel::couldSave()
|
||||||
|
{
|
||||||
|
if(_pParent)
|
||||||
|
{
|
||||||
|
QString str = _pParent->getProjectName();
|
||||||
|
if(str == QString::fromWCharArray(L"新建"))
|
||||||
|
{
|
||||||
|
ui->label_info->setText(QString::fromWCharArray(L"请输入需保存的名称"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//todo:判断输入的名称是否存在
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenameModel::onOkClicked()
|
||||||
|
{
|
||||||
|
if(_pParent)
|
||||||
|
{
|
||||||
|
if(couldSave())
|
||||||
|
{
|
||||||
|
//todo:保存
|
||||||
|
_pParent->generate(ui->lineEdit_name->text());
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
ui->label_info->clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenameModel::onCancelClicked()
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
ui->label_info->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -38,9 +38,15 @@
|
||||||
<string>模式</string>
|
<string>模式</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuProject">
|
||||||
|
<property name="title">
|
||||||
|
<string>工程模</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuView"/>
|
<addaction name="menuView"/>
|
||||||
<addaction name="menuMode"/>
|
<addaction name="menuMode"/>
|
||||||
|
<addaction name="menuProject"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QToolBar" name="toolBar">
|
<widget class="QToolBar" name="toolBar">
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,469 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>projectModelDlg</class>
|
||||||
|
<widget class="QDialog" name="projectModelDlg">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1021</width>
|
||||||
|
<height>669</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QWidget#widget{
|
||||||
|
background-color: rgb(232, 232, 232);
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,3">
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget_left" native="true">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(200, 200, 200);</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="widget_2" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(165, 165, 165);
|
||||||
|
font: 12pt "Microsoft YaHei UI";
|
||||||
|
color: rgb(8, 8, 8);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>模型索引</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeView" name="treeView_model">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<attribute name="headerVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="page">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget_3" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(165, 165, 165);
|
||||||
|
font: 12pt "Microsoft YaHei UI";
|
||||||
|
color: rgb(8, 8, 8);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>关联图元</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListView" name="listView_icon"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_linkState">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">font: 12pt "Microsoft YaHei UI";
|
||||||
|
color: rgb(8, 8, 8);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>关联状态:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="page_2"/>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget_right" native="true">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QWidget#widget_right{
|
||||||
|
background-color: rgb(200, 200, 200);
|
||||||
|
}
|
||||||
|
QWidget{
|
||||||
|
color: rgb(3, 3, 3);
|
||||||
|
font: 12pt "Microsoft YaHei UI";
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="2" column="2" rowspan="4">
|
||||||
|
<widget class="QTreeView" name="treeView_sub">
|
||||||
|
<attribute name="headerVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QPushButton" name="btn_apply">
|
||||||
|
<property name="text">
|
||||||
|
<string>>></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>156</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0" colspan="3">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>28</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_generate">
|
||||||
|
<property name="text">
|
||||||
|
<string>生成</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>18</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_save">
|
||||||
|
<property name="text">
|
||||||
|
<string>保存</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>13</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_cancel">
|
||||||
|
<property name="text">
|
||||||
|
<string>取消</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>156</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" rowspan="4">
|
||||||
|
<widget class="QTreeView" name="treeView_base">
|
||||||
|
<attribute name="headerVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QPushButton" name="btn_revoke">
|
||||||
|
<property name="text">
|
||||||
|
<string><<</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="3">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_5">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Microsoft YaHei UI</family>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
<italic>false</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>元模:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="cb_baseModel"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Microsoft YaHei UI</family>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
<italic>false</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>工程模:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="cb_projectModel">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Microsoft YaHei UI</family>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
<italic>false</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>属性类别:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="cb_property"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_6">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(165, 165, 165);
|
||||||
|
font: 12pt "Microsoft YaHei UI";
|
||||||
|
color: rgb(8, 8, 8);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>元模型属性</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(165, 165, 165);
|
||||||
|
font: 12pt "Microsoft YaHei UI";
|
||||||
|
color: rgb(8, 8, 8);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>工程模型属性</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_info">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(200, 200, 200);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
|
|
@ -0,0 +1,177 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>renameModel</class>
|
||||||
|
<widget class="QDialog" name="renameModel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>319</width>
|
||||||
|
<height>129</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalSpacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="verticalSpacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0" colspan="3">
|
||||||
|
<widget class="QLabel" name="label_title">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(205, 205, 205);
|
||||||
|
color: rgb(10, 10, 10);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>重命名</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>64</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>名称:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEdit_name"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>提示:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="label_info">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>63</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="3">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_ok">
|
||||||
|
<property name="text">
|
||||||
|
<string>确定</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_cancel">
|
||||||
|
<property name="text">
|
||||||
|
<string>取消</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_5">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Loading…
Reference in New Issue