修改模型信息时,如果模型名称发生变化,对应节点同步更新
This commit is contained in:
parent
668aef03c1
commit
4c3f3db44b
|
|
@ -32,6 +32,7 @@ public:
|
|||
QModelIndex getConnNodeIndex(const QString& name);
|
||||
void addDataModel(const QString& connection, Model& model);
|
||||
void removeDataModel(DBStructureNode*);
|
||||
void updateDataModelName(const QString& connection, int modelID, const QString& name);
|
||||
void addDataGroup(const QString& connection, int modelID, QVector<int> groups);
|
||||
void removeDataGroup(DBStructureNode*);
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ private slots:
|
|||
void onSIG_connectionStatusChanged(const QString& strConnectionName, bool bConnected);
|
||||
void onSIG_addModel(Model&);
|
||||
void onSIG_addGroups(int, QVector<int>);
|
||||
void onSIG_updateModelNodeText(int, const QString&);
|
||||
//void onSIG_addAttributes();
|
||||
void onSIG_openAttributeInfo(const QString&, ModelAttributeGroup&);
|
||||
void onSIG_closeAttributeInfo(ModelAttributeGroup&);
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ private:
|
|||
|
||||
signals:
|
||||
void addModel(Model&);
|
||||
void updateModelNodeText(int, const QString&);
|
||||
|
||||
public slots:
|
||||
void onBtnClicked_selectImage();
|
||||
|
|
|
|||
|
|
@ -239,6 +239,27 @@ void DBStructureModel::removeDataModel(DBStructureNode* modelNode)
|
|||
}
|
||||
}
|
||||
|
||||
void DBStructureModel::updateDataModelName(const QString& connection, int modelID, const QString& name)
|
||||
{
|
||||
DBStructureNode* connNode = getConnectionNode(connection);
|
||||
if(!connNode)
|
||||
{
|
||||
LOG_ERROR("DBStructureModel", QString::fromWCharArray(L"更改模型名称时获取ConnectionNode失败,节点名称:%1").arg(connection));
|
||||
return;
|
||||
}
|
||||
|
||||
DBStructureNode* modelNode = getModelNode(connNode, modelID);
|
||||
if(!connNode)
|
||||
{
|
||||
LOG_ERROR("DBStructureModel", QString::fromWCharArray(L"更改模型名称时获取ModelNode失败,节点ID:%1").arg(modelID));
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndex connIndex = index(connNode->row(), 0, QModelIndex());
|
||||
QModelIndex modelIndex = index(modelNode->row(), 0, connIndex);
|
||||
setData(modelIndex, name);
|
||||
}
|
||||
|
||||
void DBStructureModel::addDataGroup(const QString& connection, int modelID, QVector<int> groups)
|
||||
{
|
||||
DBStructureNode* connNode = getConnectionNode(connection);
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ void MainWindow::onActionTrigger_addModel()
|
|||
m_pModelInfoDialog->setMainWindow(this);
|
||||
m_pModelInfoDialog->installEventFilter(this);
|
||||
connect(m_pModelInfoDialog, &ModelInfoEditDialog::addModel, this, &MainWindow::onSIG_addModel);
|
||||
connect(m_pModelInfoDialog, &ModelInfoEditDialog::updateModelNodeText, this, &MainWindow::onSIG_updateModelNodeText);
|
||||
connect(m_pModelInfoDialog, &ModelInfoEditDialog::finished, this, [=]{ MaskManager::instance()->hideMask(m_pModelInfoDialog);});
|
||||
}
|
||||
|
||||
|
|
@ -237,6 +238,7 @@ void MainWindow::onActionTrigger_updateModel(int modelID)
|
|||
m_pModelInfoDialog->setMainWindow(this);
|
||||
m_pModelInfoDialog->installEventFilter(this);
|
||||
connect(m_pModelInfoDialog, &ModelInfoEditDialog::addModel, this, &MainWindow::onSIG_addModel);
|
||||
connect(m_pModelInfoDialog, &ModelInfoEditDialog::updateModelNodeText, this, &MainWindow::onSIG_updateModelNodeText);
|
||||
connect(m_pModelInfoDialog, &ModelInfoEditDialog::finished, this, [=]{ MaskManager::instance()->hideMask(m_pModelInfoDialog);});
|
||||
}
|
||||
|
||||
|
|
@ -349,6 +351,12 @@ void MainWindow::onSIG_addGroups(int modelID, QVector<int> groups)
|
|||
m_pDBStrutureModel->addDataGroup(connection, modelID, groups);
|
||||
}
|
||||
|
||||
void MainWindow::onSIG_updateModelNodeText(int modelID, const QString& text)
|
||||
{
|
||||
QString connection = m_pDBStrutureView->curConnection();
|
||||
m_pDBStrutureModel->updateDataModelName(connection, modelID, text);
|
||||
}
|
||||
|
||||
void MainWindow::onSIG_openAttributeInfo(const QString& connection, ModelAttributeGroup& attributeGroup)
|
||||
{
|
||||
if(m_dbBrowser)
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ void ModelInfoEditDialog::onBtnClicked_save()
|
|||
{
|
||||
if(modelName != m_oldName) //更新对应树节点
|
||||
{
|
||||
|
||||
emit updateModelNodeText(m_curModelID, modelName);
|
||||
}
|
||||
//计算删除和添加的属性组-转化为QSet,然后利用QSet的‘-’运算符操作
|
||||
QSet<int> oldSet(m_oldGroups.begin(), m_oldGroups.end());
|
||||
|
|
|
|||
Loading…
Reference in New Issue