From 2dfdb84c517e297b95dec8e088e44d4c4503f674 Mon Sep 17 00:00:00 2001 From: duanshengchao <519970194@qq.com> Date: Thu, 5 Jun 2025 16:42:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B8=BB=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=A0=8F=E4=B8=AD=E7=9A=84=E2=80=98=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E2=80=99=E6=8C=89=E9=92=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/dbStructureView.h | 1 + include/mainwindow.h | 3 ++- source/dbStructureView.cpp | 22 ++++++++++++++++++++++ source/mainwindow.cpp | 9 ++++++++- ui/mainwindow.ui | 22 ---------------------- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/include/dbStructureView.h b/include/dbStructureView.h index 35382aa..b8d4f46 100644 --- a/include/dbStructureView.h +++ b/include/dbStructureView.h @@ -20,6 +20,7 @@ public: void disconnectCurConnection(); const QString curConnection(); void onActionTrigger_removeModel(); + void onActionTrigger_refresh(); protected: void mouseDoubleClickEvent(QMouseEvent* event) override; diff --git a/include/mainwindow.h b/include/mainwindow.h index e3cde12..335a28f 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -58,7 +58,8 @@ private slots: void onActionTrigger_addModel(); void onActionTrigger_updateModel(int); void onActionTrigger_removeModel(); - void onActionTrigger_addGroup(int); + void onActionTrigger_refresh(); + void onActionTrigger_addGroup(int); void onSIG_addConnection(const DatabaseConfig&); void onSIG_updateConnectionInfo(const DatabaseConfig&); diff --git a/source/dbStructureView.cpp b/source/dbStructureView.cpp index afec31b..d782f35 100644 --- a/source/dbStructureView.cpp +++ b/source/dbStructureView.cpp @@ -191,6 +191,7 @@ DBStructureNode* DBStructureView::currentNode() void DBStructureView::onActionTrigger_removeModel() { DBStructureNode* node = currentNode(); + if(!node || (node->type() != TableNode && node->type() != GroupNode)) { if(m_pMainWindow) @@ -225,6 +226,27 @@ void DBStructureView::onActionTrigger_removeModel() } } +void DBStructureView::onActionTrigger_refresh() +{ + DBStructureNode* node = currentNode(); + if(!node) + return; + + if(node->type() == ConnectionNode && node->status() == Connect) + { + QString connName = node->name(); + DBStructureModel* model = dynamic_cast(this->model()); + if(model) + model->refreshStructure_Connection(connName); + } + else if(node && node->type() == TableNode) + { + DBStructureModel* model = dynamic_cast(this->model()); + if(model && node->parentNode()) + model->refreshStructure_Model(node->parentNode()->name(), node->data(Qt::UserRole + NodeDataRole::ID).toInt()); + } +} + void DBStructureView::itemDoubleClick(const QModelIndex& index) { DBStructureNode* node = static_cast(index.internalPointer()); diff --git a/source/mainwindow.cpp b/source/mainwindow.cpp index b83eaf0..e6c5324 100644 --- a/source/mainwindow.cpp +++ b/source/mainwindow.cpp @@ -67,6 +67,8 @@ void MainWindow::initialize() connect(ui->createTableAction, &QAction::triggered, this, &MainWindow::onActionTrigger_addModel); connect(ui->deleteTableAction, &QAction::triggered, this, &MainWindow::onActionTrigger_removeModel); + connect(ui->refreshAction, &QAction::triggered, this, &MainWindow::onActionTrigger_refresh); + connect(&SqlQueryExecutor::instance(), &SqlQueryExecutor::errorOccurred, this, &MainWindow::onSIG_errorFormSQLExecutor); MaskManager::initialize(this); @@ -268,6 +270,11 @@ void MainWindow::onActionTrigger_removeModel() if(m_pDBStrutureView) m_pDBStrutureView->onActionTrigger_removeModel(); } +void MainWindow::onActionTrigger_refresh() +{ + if(m_pDBStrutureView) + m_pDBStrutureView->onActionTrigger_refresh(); +} void MainWindow::onSIG_addConnection(const DatabaseConfig& config) { @@ -338,7 +345,7 @@ void MainWindow::onSIG_connectionStatusChanged(const QString& strConnectionName, ui->importAciton->setEnabled(bConnected); ui->exportAction->setEnabled(bConnected); ui->refreshAction->setEnabled(bConnected); - ui->saveAction->setEnabled(bConnected); + //ui->saveAction->setEnabled(bConnected); } void MainWindow::onSIG_addModel(Model& model) diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index 087d024..24b8058 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -261,7 +261,6 @@ background-color:rgb(211, 241, 250); - @@ -357,27 +356,6 @@ background-color:rgb(211, 241, 250); QAction::MenuRole::NoRole - - - false - - - - :/img/images/icon_save.png:/img/images/icon_save.png - - - 保存 - - - 保存 - - - Ctrl+S - - - QAction::MenuRole::NoRole - -