增加数据(属性)浏览框架:dbBrowser

This commit is contained in:
duanshengchao 2025-03-18 18:35:30 +08:00
parent d1381e8c4b
commit 492ddb5a36
25 changed files with 675 additions and 4 deletions

View File

@ -55,6 +55,7 @@ set(CPP_SOURCE_FILES
set(UI_FILES
ui/mainWindow.ui
ui/dbBrowser.ui
ui/connectionDialog.ui
ui/messageDialog.ui
ui/modelInfoEditDialog.ui

View File

@ -0,0 +1,20 @@
#include <QWidget>
QT_BEGIN_NAMESPACE
namespace Ui {
class DatabaseBrowser;
}
QT_END_NAMESPACE
class DatabaseBrowser : public QWidget
{
Q_OBJECT
public:
DatabaseBrowser(QWidget *parent = nullptr);
~DatabaseBrowser();
private:
Ui::DatabaseBrowser *ui;
};

View File

@ -7,6 +7,7 @@
#include "messageDialog.h"
class DatabaseManager;
class DatabaseBrowser;
class ConnectionDialog;
class DBStructureView;
class DBStructureModel;
@ -38,6 +39,7 @@ private:
Ui::MainWindow *ui;
DatabaseManager* m_dbManager;
DatabaseBrowser* m_dbBrowser;
QSqlError m_lastSqlError;
MessageDialog* m_pMessageDialog;
ConnectionDialog* m_pConnectionDialog;

View File

@ -1,5 +1,21 @@
<RCC>
<qresource prefix="img">
<file>images/icon_first.png</file>
<file>images/icon_last.png</file>
<file>images/icon_next.png</file>
<file>images/icon_previous.png</file>
<file>images/icon_refresh3.png</file>
<file>images/icon_close.png</file>
<file>images/icon_done.png</file>
<file>images/icon_plus.png</file>
<file>images/icon_subtra.png</file>
<file>images/icon_save2.png</file>
<file>images/icon_copy.png</file>
<file>images/icon_paste.png</file>
<file>images/icon_download.png</file>
<file>images/icon_refresh2.png</file>
<file>images/icon_addItem.png</file>
<file>images/icon_remove3.png</file>
<file>images/icon_hierarchy2.png</file>
<file>images/icon_add_hover.png</file>
<file>images/icon_remove2.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 810 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

View File

@ -0,0 +1,14 @@
#include "dbBrowser.h"
#include "ui_dbBrowser.h"
DatabaseBrowser::DatabaseBrowser(QWidget *parent)
: QWidget(parent)
, ui(new Ui::DatabaseBrowser)
{
ui->setupUi(this);
}
DatabaseBrowser::~DatabaseBrowser()
{
delete ui;
}

View File

@ -2,6 +2,7 @@
#include "./ui_mainwindow.h"
#include "dbManager.h"
#include "dbBrowser.h"
#include "connectionDialog.h"
#include "dbStructureView.h"
#include "dbStructureModel.h"
@ -16,6 +17,7 @@ MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, m_dbManager(nullptr)
, m_dbBrowser(nullptr)
, m_pMessageDialog(nullptr)
, m_pConnectionDialog(nullptr)
, m_pModelInfoDialog(nullptr)
@ -62,6 +64,9 @@ void MainWindow::initialize()
connect(m_dbManager, &DatabaseManager::errorOccurred, this, &MainWindow::onSIG_errorFromDBManger);
connect(m_dbManager, &DatabaseManager::connectionStatusChanged, this, &MainWindow::onSIG_connectionStatusChanged);
m_dbBrowser = new DatabaseBrowser(this);
ui->layoutAttributeBrowser->addWidget(m_dbBrowser);
m_pDBStrutureView = new DBStructureView(m_dbManager, this);
m_pDBStrutureView->setMainWindow(this);
connect(m_pDBStrutureView, &DBStructureView::actionTrigger_addModel, this, &MainWindow::onActionTrigger_addModel);
@ -74,8 +79,13 @@ void MainWindow::initialize()
int nWidth = screen->size().width() * 0.8;
int nHeight = screen->size().height() * 0.8;
this->resize(nWidth, nHeight);
ui->splitter->setStretchFactor(0, 1);
ui->splitter->setStretchFactor(1, 10);
//在子部件内含有复杂布局和嵌套空间的时候setStretchFactor会失效固采用setSizes的方法来设置初始大小
QVector<double> factor{1.0, 6.0};
int nDBStructureWidth = nWidth * (factor.at(0) / (factor.at(0) + factor.at(1)));
int nDBBrowserWidth = nWidth - nDBStructureWidth;
ui->splitter->setSizes({nDBStructureWidth, nDBBrowserWidth});
// ui->splitter->setStretchFactor(0, 1);
// ui->splitter->setStretchFactor(1, 7);
}
void MainWindow::showMessageDialog(MessageDialogType type,const QString& strTitle,const QString& strContent)

View File

@ -76,7 +76,6 @@ QSqlQuery SqlQueryExecutor::executeSQL(const QString& strConnectionName, const Q
throw; // 重新抛出异常
}
return sqlQuery;
}
//多条批量SQL语句执行接口

596
ui/dbBrowser.ui Normal file
View File

@ -0,0 +1,596 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DatabaseBrowser</class>
<widget class="QWidget" name="DatabaseBrowser">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1192</width>
<height>597</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<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="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
<iconset resource="../resource/PowerModeler.qrc">
<normaloff>:/img/images/icon_hierarchy2.png</normaloff>:/img/images/icon_hierarchy2.png</iconset>
</attribute>
<attribute name="title">
<string>NULL</string>
</attribute>
<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="QTableView" name="tableView"/>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QWidget" name="toolBar" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>31</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>31</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QWidget #toolBar
{
}
QPushButton
{
border: 0px solid rgb(205,205,205);
border-radius:0px;
}
QPushButton:hover
{
background-color:rgba(70,130,180,35);
}
QPushButton:pressed
{
background-color:rgba(70,130,180,65);
}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetNoConstraint</enum>
</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="recordControlPanel" native="true">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<widget class="QPushButton" name="btnAdd">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>5</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="toolTip">
<string>添加</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resource/PowerModeler.qrc">
<normaloff>:/img/images/icon_plus.png</normaloff>:/img/images/icon_plus.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
<widget class="QPushButton" name="btnRemove">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>36</x>
<y>5</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="toolTip">
<string>删除</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resource/PowerModeler.qrc">
<normaloff>:/img/images/icon_subtra.png</normaloff>:/img/images/icon_subtra.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
<widget class="QPushButton" name="btnSave">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>62</x>
<y>5</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="toolTip">
<string>提交更改</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resource/PowerModeler.qrc">
<normaloff>:/img/images/icon_done.png</normaloff>:/img/images/icon_done.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
<widget class="QPushButton" name="btnCancle">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>88</x>
<y>5</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="toolTip">
<string>取销更改</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resource/PowerModeler.qrc">
<normaloff>:/img/images/icon_close.png</normaloff>:/img/images/icon_close.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
<widget class="QPushButton" name="btnRefresh">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>114</x>
<y>5</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="toolTip">
<string>刷新</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resource/PowerModeler.qrc">
<normaloff>:/img/images/icon_refresh3.png</normaloff>:/img/images/icon_refresh3.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>827</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="pageControlPanel" native="true">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<widget class="QLineEdit" name="lineEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>108</x>
<y>5</y>
<width>41</width>
<height>21</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>41</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>41</width>
<height>21</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border:0px;
background-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>1</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="btnFirstPage">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>68</x>
<y>5</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="toolTip">
<string>第一页</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resource/PowerModeler.qrc">
<normaloff>:/img/images/icon_first.png</normaloff>:/img/images/icon_first.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
<widget class="QPushButton" name="btnLastPage">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>170</x>
<y>5</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="toolTip">
<string>最后一页</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resource/PowerModeler.qrc">
<normaloff>:/img/images/icon_last.png</normaloff>:/img/images/icon_last.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
<widget class="QPushButton" name="btnPreviousPage">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>88</x>
<y>5</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="toolTip">
<string>上一页</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resource/PowerModeler.qrc">
<normaloff>:/img/images/icon_previous.png</normaloff>:/img/images/icon_previous.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
<widget class="QPushButton" name="btnNextPage">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>150</x>
<y>5</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>21</width>
<height>21</height>
</size>
</property>
<property name="toolTip">
<string>下一页</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resource/PowerModeler.qrc">
<normaloff>:/img/images/icon_next.png</normaloff>:/img/images/icon_next.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../resource/PowerModeler.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -155,6 +155,20 @@ QTreeView::item:selected
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="layoutAttributeBrowser">
<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>
</layout>
</widget>
</widget>
</item>
@ -200,7 +214,6 @@ QTreeView::item:selected
<addaction name="menu_4"/>
<addaction name="menu_5"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>