add alter dynamic table/fix bugs
This commit is contained in:
parent
ece2debbad
commit
4f3c865126
|
|
@ -465,6 +465,7 @@ class GraphicsBaseModelItem : public GraphicsBaseItem //基模item
|
||||||
public:
|
public:
|
||||||
GraphicsBaseModelItem(QGraphicsItem *parent);
|
GraphicsBaseModelItem(QGraphicsItem *parent);
|
||||||
virtual ~GraphicsBaseModelItem();
|
virtual ~GraphicsBaseModelItem();
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||||
protected:
|
protected:
|
||||||
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange, const QVariant&);
|
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange, const QVariant&);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ QT_END_NAMESPACE
|
||||||
|
|
||||||
class GraphicsBaseModelItem;
|
class GraphicsBaseModelItem;
|
||||||
class BaseModelProperty;
|
class BaseModelProperty;
|
||||||
|
class FixedPortsModel;
|
||||||
|
|
||||||
class ProjectModelSetting : public QDialog
|
class ProjectModelSetting : public QDialog
|
||||||
{
|
{
|
||||||
|
|
@ -21,22 +22,26 @@ public:
|
||||||
void loadPicture();
|
void loadPicture();
|
||||||
void setSelectedItems(QStringList);
|
void setSelectedItems(QStringList);
|
||||||
void showDlg(GraphicsBaseModelItem*);
|
void showDlg(GraphicsBaseModelItem*);
|
||||||
void loadProject(const QString& sMeta);
|
void setController(FixedPortsModel* p){_controller = p;}
|
||||||
protected:
|
//void loadProject(const QString& sMeta);
|
||||||
|
public slots:
|
||||||
void onOkClicked();
|
void onOkClicked();
|
||||||
void onCancelClicked();
|
void onCancelClicked();
|
||||||
void onSaveAsClicked();
|
//void onSaveAsClicked();
|
||||||
void onSelectClicked(); //选择图片
|
void onSelectClicked(); //选择图片
|
||||||
|
|
||||||
void onAddClicked(); //添加属性
|
void onAddClicked(); //添加属性
|
||||||
void onDecreaseClicked(); //减少属性
|
void onDecreaseClicked(); //减少属性
|
||||||
|
void onSaveClicked();
|
||||||
public slots:
|
public slots:
|
||||||
void onSaveAsFinished(); //另存输入完毕
|
//void onSaveAsFinished(); //另存输入完毕
|
||||||
void onCurrentTextChanged(const QString&);
|
void onCurrentTextChanged(const QString&);
|
||||||
private:
|
private:
|
||||||
void showTestPic(QByteArray);
|
void showTestPic(QByteArray);
|
||||||
|
void loadModel(const QString&);
|
||||||
private:
|
private:
|
||||||
Ui::projectModelSetting *ui;
|
Ui::projectModelSetting *ui;
|
||||||
|
FixedPortsModel* _controller;
|
||||||
BaseModelProperty* _curItemData; //当前操作对象的属性
|
BaseModelProperty* _curItemData; //当前操作对象的属性
|
||||||
QString _curPath;
|
QString _curPath;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -77,11 +77,12 @@ void ElectricBaseModelLineItem::paint(QPainter* painter, const QStyleOptionGraph
|
||||||
{
|
{
|
||||||
if (option->state & QStyle::State_Selected)
|
if (option->state & QStyle::State_Selected)
|
||||||
{
|
{
|
||||||
painter->setPen(Qt::red);
|
painter->setPen(QColor(135,206,235,180));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
painter->setPen(m_pen);
|
painter->setPen(m_pen);
|
||||||
|
GraphicsBaseModelItem::paint(painter,option,widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setBrush(m_brush);
|
painter->setBrush(m_brush);
|
||||||
|
|
|
||||||
|
|
@ -63,39 +63,11 @@ void ElectricBaseModelSvgItem::paint(QPainter* painter, const QStyleOptionGraphi
|
||||||
if (option->state & QStyle::State_Selected) //是选中状态,绘制选中框
|
if (option->state & QStyle::State_Selected) //是选中状态,绘制选中框
|
||||||
{
|
{
|
||||||
renderSelectBackground(painter);
|
renderSelectBackground(painter);
|
||||||
/*int nPenWidth = 1;
|
|
||||||
painter->setPen(QPen(QColor(135,206,235,180))); //蓝色的外框
|
|
||||||
|
|
||||||
painter->setBrush(QBrush(QColor(135,206,235,180)));
|
|
||||||
|
|
||||||
double dx = m_boundingRect_selected.x();
|
|
||||||
double dy = m_boundingRect_selected.y();
|
|
||||||
double dWidth = m_boundingRect_selected.width();
|
|
||||||
double dHeight = m_boundingRect_selected.height();
|
|
||||||
|
|
||||||
|
|
||||||
//画弧线0度是3点钟方向
|
|
||||||
if(dWidth > dHeight)
|
|
||||||
{
|
|
||||||
painter->drawRect(m_boundingRect_selected);
|
|
||||||
painter->drawChord(dx-dHeight*0.5,dy,dHeight,dHeight,90*16,180*16);
|
|
||||||
painter->drawChord(dx+dWidth-dHeight*0.5,dy,dHeight,dHeight,(-90)*16,180*16);
|
|
||||||
}
|
|
||||||
else if(dWidth < dHeight)
|
|
||||||
{
|
|
||||||
painter->drawRect(m_boundingRect_selected);
|
|
||||||
painter->drawChord(dx,dy-dWidth*0.5,dWidth,dWidth,0*16,180*16);
|
|
||||||
painter->drawChord(dx,dy+dHeight-dWidth*0.5,dWidth,dWidth,180*16,180*16);
|
|
||||||
//painter->drawChord(dx+dWidth-dHeight*0.5,dy,dHeight,dHeight,(-90)*16,180*16);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
painter->drawEllipse(QPointF(dx+dWidth*0.5,dy+dHeight*0.5),dHeight*0.5,dHeight*0.5);
|
|
||||||
}*/
|
|
||||||
painter->drawText(QPointF(0,0),"yes");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
painter->drawText(QPointF(0,0),"no");
|
{
|
||||||
|
GraphicsBaseModelItem::paint(painter,option,widget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElectricBaseModelSvgItem::loadSvg(const QByteArray& data)
|
void ElectricBaseModelSvgItem::loadSvg(const QByteArray& data)
|
||||||
|
|
|
||||||
|
|
@ -1118,6 +1118,7 @@ void FixedPortsModel::showProjectModelSettingDlg(GraphicsBaseModelItem* srcItem)
|
||||||
if(m_proModelSettingDlg == nullptr)
|
if(m_proModelSettingDlg == nullptr)
|
||||||
{
|
{
|
||||||
m_proModelSettingDlg = new ProjectModelSetting(_widget);
|
m_proModelSettingDlg = new ProjectModelSetting(_widget);
|
||||||
|
m_proModelSettingDlg->setController(this);
|
||||||
}
|
}
|
||||||
m_proModelSettingDlg->showDlg(srcItem);
|
m_proModelSettingDlg->showDlg(srcItem);
|
||||||
}
|
}
|
||||||
|
|
@ -1621,6 +1622,8 @@ void FixedPortsModel::addTestData()
|
||||||
addBayItem(bayId,pBay);
|
addBayItem(bayId,pBay);
|
||||||
addItemsToBay(lst,pBay);
|
addItemsToBay(lst,pBay);
|
||||||
_scene->addItem(pBay);
|
_scene->addItem(pBay);
|
||||||
|
QString s = pageName();
|
||||||
|
int a = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject FixedPortsModel::turnListToJson(QList<QUuid> lst,QString sInerTag,QString sOutTag)
|
QJsonObject FixedPortsModel::turnListToJson(QList<QUuid> lst,QString sInerTag,QString sOutTag)
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,16 @@ GraphicsBaseModelItem::~GraphicsBaseModelItem()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicsBaseModelItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
if(getProperty()->modelName().isEmpty())
|
||||||
|
{
|
||||||
|
painter->setPen(QColor(255,0,0,80));
|
||||||
|
painter->setBrush(QColor(255,0,0,80));
|
||||||
|
painter->drawRoundedRect(m_boundingRect,10,10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVariant GraphicsBaseModelItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value)
|
QVariant GraphicsBaseModelItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value)
|
||||||
{
|
{
|
||||||
if (change == QGraphicsItem::ItemSelectedHasChanged)
|
if (change == QGraphicsItem::ItemSelectedHasChanged)
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,15 @@ void ItemPropertyDlg::showDlg(modelDataInfo dataInfo,QUuid uuid,GraphicsProjectM
|
||||||
curUuid_ = uuid;
|
curUuid_ = uuid;
|
||||||
_curModel = dataInfo.modelName;
|
_curModel = dataInfo.modelName;
|
||||||
_curItem = pItem;
|
_curItem = pItem;
|
||||||
QString firstName = groupInfo_.constBegin().key();
|
|
||||||
onGroupSelected(firstName); //打开默认显示第一个属性组
|
QString str;
|
||||||
|
auto btn = dynamic_cast<QPushButton*>(btnGroup_->checkedButton());
|
||||||
|
if(btn == nullptr){
|
||||||
|
str = groupInfo_.constBegin().key(); //打开默认显示第一个属性组
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
str = btn->text();
|
||||||
|
}
|
||||||
|
onGroupSelected(str);
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,18 @@
|
||||||
#include "ui_projectModelSetting.h"
|
#include "ui_projectModelSetting.h"
|
||||||
#include "baseProperty.h"
|
#include "baseProperty.h"
|
||||||
#include "graphicsItem/graphicsBaseItem.h"
|
#include "graphicsItem/graphicsBaseItem.h"
|
||||||
|
#include "graphicsDataModel/fixedPortsModel.h"
|
||||||
#include "projectModelManager.h"
|
#include "projectModelManager.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "dataBase.h"
|
||||||
|
|
||||||
ProjectModelSetting::ProjectModelSetting(QWidget *parent)
|
ProjectModelSetting::ProjectModelSetting(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
,ui(new Ui::projectModelSetting)
|
,ui(new Ui::projectModelSetting)
|
||||||
,_curItemData(nullptr)
|
,_curItemData(nullptr)
|
||||||
|
,_controller(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||||
|
|
@ -33,19 +36,19 @@ void ProjectModelSetting::initial()
|
||||||
{
|
{
|
||||||
connect(ui->btn_ok,&QPushButton::clicked,this,&ProjectModelSetting::onOkClicked);
|
connect(ui->btn_ok,&QPushButton::clicked,this,&ProjectModelSetting::onOkClicked);
|
||||||
connect(ui->btn_cancel,&QPushButton::clicked,this,&ProjectModelSetting::onCancelClicked);
|
connect(ui->btn_cancel,&QPushButton::clicked,this,&ProjectModelSetting::onCancelClicked);
|
||||||
connect(ui->btn_saveAs,&QPushButton::clicked,this,&ProjectModelSetting::onSaveAsClicked);
|
//connect(ui->btn_saveAs,&QPushButton::clicked,this,&ProjectModelSetting::onSaveAsClicked);
|
||||||
connect(ui->btn_select,&QPushButton::clicked,this,&ProjectModelSetting::onSelectClicked);
|
connect(ui->btn_select,&QPushButton::clicked,this,&ProjectModelSetting::onSelectClicked);
|
||||||
|
|
||||||
connect(ui->btn_apply,&QPushButton::clicked,this,&ProjectModelSetting::onAddClicked);
|
connect(ui->btn_apply,&QPushButton::clicked,this,&ProjectModelSetting::onAddClicked);
|
||||||
connect(ui->btn_revoke,&QPushButton::clicked,this,&ProjectModelSetting::onDecreaseClicked);
|
connect(ui->btn_revoke,&QPushButton::clicked,this,&ProjectModelSetting::onDecreaseClicked);
|
||||||
|
|
||||||
connect(ui->le_saveAs,&QLineEdit::editingFinished,this,&ProjectModelSetting::onSaveAsFinished);
|
//connect(ui->le_saveAs,&QLineEdit::editingFinished,this,&ProjectModelSetting::onSaveAsFinished);
|
||||||
connect(ui->cb_modelType,&QComboBox::currentTextChanged,this,&ProjectModelSetting::onCurrentTextChanged);
|
//connect(ui->cb_modelType,&QComboBox::currentTextChanged,this,&ProjectModelSetting::onCurrentTextChanged);
|
||||||
_curPath = QCoreApplication::applicationDirPath()+"/proModelImage/";
|
_curPath = QCoreApplication::applicationDirPath()+"/proModelImage/";
|
||||||
ui->cb_modelType->setPlaceholderText(" ");
|
//ui->cb_modelType->setPlaceholderText(" ");
|
||||||
QRegularExpression regExp("[a-zA-Z0-9]+");
|
/*QRegularExpression regExp("[a-zA-Z0-9]+");
|
||||||
QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp, this);
|
QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp, this);
|
||||||
ui->le_saveAs->setValidator(validator);
|
ui->le_saveAs->setValidator(validator);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectModelSetting::loadPicture()
|
void ProjectModelSetting::loadPicture()
|
||||||
|
|
@ -99,12 +102,19 @@ void ProjectModelSetting::showDlg(GraphicsBaseModelItem* srcNode)
|
||||||
QString sName = pro->name();
|
QString sName = pro->name();
|
||||||
QString sMetaModel = pro->metaModelName();
|
QString sMetaModel = pro->metaModelName();
|
||||||
QString sModel = pro->modelName();
|
QString sModel = pro->modelName();
|
||||||
|
|
||||||
|
if(sModel.isEmpty()) //模型为空直接判断名字()
|
||||||
|
{
|
||||||
|
sModel = sMetaModel+"_"+_controller->pageName();
|
||||||
|
pro->setModelName(sModel);
|
||||||
|
}
|
||||||
_curItemData = pro;
|
_curItemData = pro;
|
||||||
loadProject(sMetaModel);
|
//loadProject(sMetaModel);
|
||||||
|
|
||||||
bool bExist = ProjectModelManager::instance().ifProjectExsit(sModel);
|
bool bExist = ProjectModelManager::instance().ifProjectExsit(sModel);
|
||||||
if(bExist){ //使用存在的属性
|
if(bExist){ //使用存在的属性
|
||||||
ui->cb_modelType->setCurrentText(sModel);
|
//ui->cb_modelType->setCurrentText(sModel);
|
||||||
|
loadModel(sModel);
|
||||||
}
|
}
|
||||||
else{ //新建当前对象的属性
|
else{ //新建当前对象的属性
|
||||||
if(pro->getModelProperty().pBase == nullptr && pro->getModelProperty().pSelect == nullptr){
|
if(pro->getModelProperty().pBase == nullptr && pro->getModelProperty().pSelect == nullptr){
|
||||||
|
|
@ -117,25 +127,26 @@ void ProjectModelSetting::showDlg(GraphicsBaseModelItem* srcNode)
|
||||||
ui->treeView_sub->expandAll();
|
ui->treeView_sub->expandAll();
|
||||||
ui->treeView_base->expandAll();
|
ui->treeView_base->expandAll();
|
||||||
}
|
}
|
||||||
ui->le_saveAs->clear();
|
//ui->le_saveAs->clear();
|
||||||
ui->le_name->setText(sName);
|
ui->le_name->setText(sName);
|
||||||
ui->le_base->setText(sMetaModel);
|
ui->le_base->setText(sMetaModel);
|
||||||
}
|
}
|
||||||
loadPicture();
|
loadPicture();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectModelSetting::loadProject(const QString& sMeta)
|
/*void ProjectModelSetting::loadProject(const QString& sMeta)
|
||||||
{
|
{
|
||||||
ui->cb_modelType->blockSignals(true);
|
ui->cb_modelType->blockSignals(true);
|
||||||
ui->cb_modelType->clear();
|
ui->cb_modelType->clear();
|
||||||
QStringList lst = ProjectModelManager::instance().getProjectModelLst(sMeta);
|
QStringList lst = ProjectModelManager::instance().getProjectModelLst(sMeta);
|
||||||
ui->cb_modelType->addItems(lst);
|
ui->cb_modelType->addItems(lst);
|
||||||
ui->cb_modelType->blockSignals(false);
|
ui->cb_modelType->blockSignals(false);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void ProjectModelSetting::onOkClicked()
|
void ProjectModelSetting::onOkClicked()
|
||||||
{
|
{
|
||||||
_curItemData->setModelName(ui->cb_modelType->currentText());
|
//_curItemData->setModelName(ui->cb_modelType->currentText());
|
||||||
|
onSaveClicked();
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,7 +155,7 @@ void ProjectModelSetting::onCancelClicked()
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectModelSetting::onSaveAsClicked()
|
/*void ProjectModelSetting::onSaveAsClicked()
|
||||||
{
|
{
|
||||||
QString sModelName = ui->le_saveAs->text();
|
QString sModelName = ui->le_saveAs->text();
|
||||||
bool bExist = ProjectModelManager::instance().ifProjectExsit(sModelName);
|
bool bExist = ProjectModelManager::instance().ifProjectExsit(sModelName);
|
||||||
|
|
@ -164,7 +175,7 @@ void ProjectModelSetting::onSaveAsClicked()
|
||||||
QMessageBox::information(NULL, QString("提示"), QString::fromWCharArray(L"另存成功"));
|
QMessageBox::information(NULL, QString("提示"), QString::fromWCharArray(L"另存成功"));
|
||||||
}
|
}
|
||||||
ui->label_info->clear();
|
ui->label_info->clear();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void ProjectModelSetting::onSelectClicked()
|
void ProjectModelSetting::onSelectClicked()
|
||||||
{
|
{
|
||||||
|
|
@ -267,7 +278,71 @@ void ProjectModelSetting::onDecreaseClicked()
|
||||||
ui->treeView_base->expandAll();
|
ui->treeView_base->expandAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectModelSetting::onSaveAsFinished()
|
void ProjectModelSetting::onSaveClicked()
|
||||||
|
{
|
||||||
|
if(_curItemData){
|
||||||
|
QString sMeta = _curItemData->metaModelName();
|
||||||
|
QString sModelName = _curItemData->modelName();
|
||||||
|
|
||||||
|
bool bExist = ProjectModelManager::instance().ifProjectExsit(sModelName);
|
||||||
|
if(bExist){
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText(QString::fromWCharArray(L"提示"));
|
||||||
|
msgBox.setInformativeText(QString::fromWCharArray(L"模型将被覆盖,是否保存?"));
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel);
|
||||||
|
msgBox.setDefaultButton(QMessageBox::Save);
|
||||||
|
int ret = msgBox.exec();
|
||||||
|
|
||||||
|
switch (ret) {
|
||||||
|
case QMessageBox::Save:
|
||||||
|
{
|
||||||
|
PropertyModel pro = _curItemData->getModelProperty().deepCopy();
|
||||||
|
ProjectModelManager::instance().getData()[_curItemData->metaModelName()][sModelName] = pro;
|
||||||
|
ProjectModelManager::instance().updateSetting(_curItemData->metaModelName(),sModelName);
|
||||||
|
QMap<QString,QJsonObject> mapCheckState = DataBase::GetInstance()->getCheckStateFromManager(sModelName);
|
||||||
|
QString sRes = ProjectModelManager::instance().modifyProjectModel(sMeta,sModelName,mapCheckState);
|
||||||
|
if(!sRes.isEmpty())
|
||||||
|
{
|
||||||
|
QMessageBox::information(NULL, QString::fromWCharArray(L"提示"), QString::fromWCharArray(L"修改成功"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::information(NULL, QString::fromWCharArray(L"提示"), QString::fromWCharArray(L"修改失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QMessageBox::Cancel:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{ //新建的模型拷贝当前内容到全局队列
|
||||||
|
_curItemData->getModelProperty().modelSetting.modelName = sModelName;
|
||||||
|
PropertyModel pro = _curItemData->getModelProperty().deepCopy();
|
||||||
|
ProjectModelManager::instance().getData()[_curItemData->metaModelName()].insert(sModelName,pro);
|
||||||
|
ProjectModelManager::instance().generate(_curItemData->metaModelName(),sModelName);
|
||||||
|
ProjectModelManager::instance().updateSetting(_curItemData->metaModelName(),sModelName);
|
||||||
|
QMessageBox::information(NULL, QString("提示"), QString::fromWCharArray(L"保存成功"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_controller){
|
||||||
|
QMap<QUuid,GraphicsBaseModelItem*> mapItem = _controller->allBaseItems();
|
||||||
|
for(auto &item:mapItem)
|
||||||
|
{
|
||||||
|
ModelProperty* p = item->getProperty();
|
||||||
|
BaseModelProperty* pro = dynamic_cast<BaseModelProperty*>(p);
|
||||||
|
if(pro){
|
||||||
|
if(pro->metaModelName() == _curItemData->metaModelName()){ //将相同基模item的工程模名称都置为相同(改一个全变)
|
||||||
|
pro->setModelName(_curItemData->modelName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*void ProjectModelSetting::onSaveAsFinished()
|
||||||
{
|
{
|
||||||
QString sModelName = ui->le_saveAs->text();
|
QString sModelName = ui->le_saveAs->text();
|
||||||
bool bExist = ProjectModelManager::instance().ifProjectExsit(sModelName);
|
bool bExist = ProjectModelManager::instance().ifProjectExsit(sModelName);
|
||||||
|
|
@ -277,7 +352,7 @@ void ProjectModelSetting::onSaveAsFinished()
|
||||||
else{
|
else{
|
||||||
ui->label_info->setText(QString::fromWCharArray(L"名称可用"));
|
ui->label_info->setText(QString::fromWCharArray(L"名称可用"));
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void ProjectModelSetting::onCurrentTextChanged(const QString& text)
|
void ProjectModelSetting::onCurrentTextChanged(const QString& text)
|
||||||
{
|
{
|
||||||
|
|
@ -321,3 +396,22 @@ void ProjectModelSetting::showTestPic(QByteArray arr)
|
||||||
ui->modelImagePreview->clear();
|
ui->modelImagePreview->clear();
|
||||||
ui->modelImagePreview->setPixmap(pixmap);
|
ui->modelImagePreview->setPixmap(pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectModelSetting::loadModel(const QString& text)
|
||||||
|
{
|
||||||
|
if(text.isEmpty())
|
||||||
|
return;
|
||||||
|
if(_curItemData)
|
||||||
|
{
|
||||||
|
_curItemData->getModelProperty().release();
|
||||||
|
PropertyModel model = ProjectModelManager::instance().getData()[_curItemData->metaModelName()][text].deepCopy();
|
||||||
|
_curItemData->setModelProperty(model);
|
||||||
|
ui->treeView_base->setModel(_curItemData->getModelProperty().pBase);
|
||||||
|
ui->treeView_sub->setModel(_curItemData->getModelProperty().pSelect);
|
||||||
|
ui->treeView_sub->expandAll();
|
||||||
|
ui->treeView_base->expandAll();
|
||||||
|
loadPicture();
|
||||||
|
if(!_curItemData->getModelProperty().modelSetting.mapSvg.isEmpty())
|
||||||
|
setSelectedItems(_curItemData->getModelProperty().modelSetting.mapSvg.keys());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,10 @@ QWidget* PropertyContentDlg::createEditor(propertyStateInfo pro)
|
||||||
if(pro.type.contains("SMALLINT"))
|
if(pro.type.contains("SMALLINT"))
|
||||||
{
|
{
|
||||||
QSpinBox* spin = new QSpinBox(this);
|
QSpinBox* spin = new QSpinBox(this);
|
||||||
spin->setRange(-32768, 32767);
|
if(pro.lengthPrecision > 0)
|
||||||
|
spin->setRange(-pro.lengthPrecision,pro.lengthPrecision);
|
||||||
|
else
|
||||||
|
spin->setRange(-32768, 32767);
|
||||||
pWidget = spin;
|
pWidget = spin;
|
||||||
}
|
}
|
||||||
else if(pro.type.contains("INTEGER"))
|
else if(pro.type.contains("INTEGER"))
|
||||||
|
|
@ -50,6 +53,9 @@ QWidget* PropertyContentDlg::createEditor(propertyStateInfo pro)
|
||||||
QSpinBox* spin = new QSpinBox(this);
|
QSpinBox* spin = new QSpinBox(this);
|
||||||
if(pro.lengthPrecision > 0)
|
if(pro.lengthPrecision > 0)
|
||||||
spin->setRange(-pro.lengthPrecision,pro.lengthPrecision);
|
spin->setRange(-pro.lengthPrecision,pro.lengthPrecision);
|
||||||
|
else
|
||||||
|
spin->setRange(-32768,32767);
|
||||||
|
|
||||||
pWidget = spin;
|
pWidget = spin;
|
||||||
}
|
}
|
||||||
else if(pro.type.contains("BIGINT"))
|
else if(pro.type.contains("BIGINT"))
|
||||||
|
|
@ -63,15 +69,21 @@ QWidget* PropertyContentDlg::createEditor(propertyStateInfo pro)
|
||||||
else if(pro.type.contains("REAL"))
|
else if(pro.type.contains("REAL"))
|
||||||
{
|
{
|
||||||
QDoubleSpinBox* dbSpin = new QDoubleSpinBox(this);
|
QDoubleSpinBox* dbSpin = new QDoubleSpinBox(this);
|
||||||
dbSpin->setDecimals(6);
|
dbSpin->setDecimals(4);
|
||||||
|
if(pro.lengthPrecision > 0)
|
||||||
|
dbSpin->setRange(-pro.lengthPrecision,pro.lengthPrecision);
|
||||||
|
else
|
||||||
|
dbSpin->setRange(-9999999,9999999);
|
||||||
pWidget = dbSpin;
|
pWidget = dbSpin;
|
||||||
}
|
}
|
||||||
else if(pro.type.contains("DOUBLE PRECISION"))
|
else if(pro.type.contains("DOUBLE PRECISION"))
|
||||||
{
|
{
|
||||||
QDoubleSpinBox* dbSpin = new QDoubleSpinBox(this);
|
QDoubleSpinBox* dbSpin = new QDoubleSpinBox(this);
|
||||||
dbSpin->setDecimals(15);
|
dbSpin->setDecimals(8);
|
||||||
if(pro.lengthPrecision > 0)
|
if(pro.lengthPrecision > 0)
|
||||||
dbSpin->setRange(-pro.lengthPrecision,pro.lengthPrecision);
|
dbSpin->setRange(-pro.lengthPrecision,pro.lengthPrecision);
|
||||||
|
else
|
||||||
|
dbSpin->setRange(-9999999,9999999);
|
||||||
pWidget = dbSpin;
|
pWidget = dbSpin;
|
||||||
}
|
}
|
||||||
else if(pro.type.contains("NUMERIC") || pro.type.contains("DECIMAL"))
|
else if(pro.type.contains("NUMERIC") || pro.type.contains("DECIMAL"))
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>基本信息</string>
|
<string>基本信息</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,1,0,1">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,1">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
@ -115,6 +115,19 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<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>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
@ -129,16 +142,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>当前工程模:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="cb_modelType"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
@ -368,33 +371,6 @@ color: rgb(8, 8, 8);</string>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_saveAs">
|
|
||||||
<property name="text">
|
|
||||||
<string>工程模另存为</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="le_saveAs">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_info">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>80</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void modelChange(); //模型改变信号
|
void modelChange(); //模型改变信号
|
||||||
private:
|
private:
|
||||||
int createPropertyTable(const QString& sMeta,const QString& sProject,const QString& sGroup,QList<QStandardItem*> lstSelect,QList<QStandardItem*> lstBase,int nLinkType,bool isPublic = false); //创建属性组表并插入记录到管理表(工程名,当前项迭代器,关联图元类型)
|
int createPropertyTable(const QString& sMeta,const QString& sProject,const QString& sGroup,QList<QStandardItem*> lstSelect,QList<QStandardItem*> lstBase,int nLinkType,bool isPublic); //创建属性组表并插入记录到管理表(工程名,当前项迭代器,关联图元类型)
|
||||||
QJsonObject getSelectedState(QList<QStandardItem*> select,QList<QStandardItem*> base); //返回json格式的选中状态
|
QJsonObject getSelectedState(QList<QStandardItem*> select,QList<QStandardItem*> base); //返回json格式的选中状态
|
||||||
QString getItemDataType(const QStandardItem* pItem); //返回数据类型
|
QString getItemDataType(const QStandardItem* pItem); //返回数据类型
|
||||||
projectModelSetting getModelSetting(const QString& sMeta,const QString& sProject); //获取指定工程模的设定
|
projectModelSetting getModelSetting(const QString& sMeta,const QString& sProject); //获取指定工程模的设定
|
||||||
|
|
|
||||||
|
|
@ -626,7 +626,7 @@ QString ProjectModelManager::modifyProjectModel(const QString& sMeta,const QStri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{ //非空且库模型中不存在,新增
|
else{ //非空且库模型中不存在,新增
|
||||||
bool res = createPropertyTable(sMeta,sProject,iter.key(),lstSelected,lstBase,iter->isPublic);
|
bool res = createPropertyTable(sMeta,sProject,iter.key(),lstSelected,lstBase,0,iter->isPublic);
|
||||||
if(res)
|
if(res)
|
||||||
{
|
{
|
||||||
sRes = QString::fromWCharArray(L"修改模型成功");
|
sRes = QString::fromWCharArray(L"修改模型成功");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue