完成public类型属性组编辑自动同步
This commit is contained in:
parent
4a5a076880
commit
1695da875e
|
|
@ -44,6 +44,7 @@ set(H_HEADER_FILES
|
||||||
include/maskManager.h
|
include/maskManager.h
|
||||||
include/customBorderContainer.h
|
include/customBorderContainer.h
|
||||||
include/groupSelectionDialog.h
|
include/groupSelectionDialog.h
|
||||||
|
include/dataSyncManager.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CPP_SOURCE_FILES
|
set(CPP_SOURCE_FILES
|
||||||
|
|
@ -74,6 +75,7 @@ set(CPP_SOURCE_FILES
|
||||||
source/maskManager.cpp
|
source/maskManager.cpp
|
||||||
source/customBorderContainer.cpp
|
source/customBorderContainer.cpp
|
||||||
source/groupSelectionDialog.cpp
|
source/groupSelectionDialog.cpp
|
||||||
|
source/dataSyncManager.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(UI_FILES
|
set(UI_FILES
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public:
|
||||||
//分页控制
|
//分页控制
|
||||||
void setPageSize(int);
|
void setPageSize(int);
|
||||||
int pageSize() const;
|
int pageSize() const;
|
||||||
void setCurrentPage(int);
|
bool setCurrentPage(int);
|
||||||
int currentPage() const;
|
int currentPage() const;
|
||||||
int totalPages() const;
|
int totalPages() const;
|
||||||
void previousPage();
|
void previousPage();
|
||||||
|
|
@ -73,6 +73,7 @@ public:
|
||||||
//数据操作
|
//数据操作
|
||||||
//void setTable(const QString&);
|
//void setTable(const QString&);
|
||||||
void refresh();
|
void refresh();
|
||||||
|
void forceRefresh(); //强制刷新(不会出现询问提示,数据同步时会用到)
|
||||||
void insertRecord(int);
|
void insertRecord(int);
|
||||||
void removeRecord(int);
|
void removeRecord(int);
|
||||||
void submitChanges(); //提交更改(增、删、改)
|
void submitChanges(); //提交更改(增、删、改)
|
||||||
|
|
@ -84,6 +85,7 @@ public:
|
||||||
//others
|
//others
|
||||||
QMap<int, DataType> getDataTypes() {return m_dataTypes;}
|
QMap<int, DataType> getDataTypes() {return m_dataTypes;}
|
||||||
void triggerSyncSignal();
|
void triggerSyncSignal();
|
||||||
|
bool dataHasbeenModified() {return !m_modifiedRows.isEmpty();};
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void syncDataStatus(bool, const PaginationInfo&);
|
void syncDataStatus(bool, const PaginationInfo&);
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,15 @@ public:
|
||||||
AttributeTableDelegate* delegate() const { return m_attributeTableDelegate; }
|
AttributeTableDelegate* delegate() const { return m_attributeTableDelegate; }
|
||||||
|
|
||||||
void active();
|
void active();
|
||||||
|
void syncChangeRecord();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void showMessage(MessageDialogType,const QString&,const QString&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_connection;
|
QString m_connection;
|
||||||
QString m_attributeTable;
|
QString m_attributeTable;
|
||||||
|
AttributeGroup m_attributeGroup;
|
||||||
ModelAttributeGroup m_modelAttributeGroup;
|
ModelAttributeGroup m_modelAttributeGroup;
|
||||||
|
|
||||||
QTableView* m_tableView;
|
QTableView* m_tableView;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef DATASYNCMANAGER_H
|
||||||
|
#define DATASYNCMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QHash>
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
class DataSyncManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
static DataSyncManager& instance();
|
||||||
|
|
||||||
|
void registerPublicGroup(const QString&); //注册公共属性组
|
||||||
|
AttributeGroup getGroup(int);
|
||||||
|
void syncGroupVersion(int, int);
|
||||||
|
int getGropuVersion(int);//获取属性组的版本号
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit DataSyncManager();
|
||||||
|
~DataSyncManager();
|
||||||
|
|
||||||
|
QHash<int, AttributeGroup> m_publicGroups;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //DATASYNCMANAGER_H
|
||||||
|
|
@ -24,6 +24,7 @@ public:
|
||||||
void setMainWindow(MainWindow*);
|
void setMainWindow(MainWindow*);
|
||||||
void addTab_attribute(const QString&, ModelAttributeGroup&);
|
void addTab_attribute(const QString&, ModelAttributeGroup&);
|
||||||
void closeTab_attribute(ModelAttributeGroup&);
|
void closeTab_attribute(ModelAttributeGroup&);
|
||||||
|
void closeAllTab_attribute();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTabCloseRequested(int);
|
void onTabCloseRequested(int);
|
||||||
|
|
@ -37,12 +38,19 @@ private slots:
|
||||||
void onBtnClicked_cancleChanges();
|
void onBtnClicked_cancleChanges();
|
||||||
void onBtnClicked_refreshData();
|
void onBtnClicked_refreshData();
|
||||||
|
|
||||||
|
void onBtnClicked_firstPage();
|
||||||
|
void onBtnClicked_previousPage();
|
||||||
|
void onBtnClicked_nextPage();
|
||||||
|
void onBtnClicked_lastPage();
|
||||||
|
void onEditingFinished_page();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int tabIndex(const QString&);
|
int tabIndex(const QString&);
|
||||||
|
|
||||||
Ui::DatabaseBrowser *ui;
|
Ui::DatabaseBrowser *ui;
|
||||||
MainWindow* m_pMainWindow;
|
MainWindow* m_pMainWindow;
|
||||||
QList<AttributeView> m_attributeViewList;
|
QList<AttributeView> m_attributeViewList;
|
||||||
|
int m_previousTabIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //DBBROWSER_H
|
#endif //DBBROWSER_H
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ signals:
|
||||||
void actionTrigger_addGroup(int);
|
void actionTrigger_addGroup(int);
|
||||||
void openAttributeInfo(const QString&, ModelAttributeGroup&);
|
void openAttributeInfo(const QString&, ModelAttributeGroup&);
|
||||||
void closeAttributeInfo(ModelAttributeGroup&);
|
void closeAttributeInfo(ModelAttributeGroup&);
|
||||||
|
void closeAllAttributeInfo();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void itemDoubleClick(const QModelIndex&);
|
void itemDoubleClick(const QModelIndex&);
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ struct AttributeGroup
|
||||||
QString type; //英文标识名称
|
QString type; //英文标识名称
|
||||||
QString remark;
|
QString remark;
|
||||||
bool isPublic;
|
bool isPublic;
|
||||||
|
int version; //用来及记录pucblic类型属性组数据同步的标记
|
||||||
|
|
||||||
AttributeGroup()
|
AttributeGroup()
|
||||||
{
|
{
|
||||||
|
|
@ -53,15 +54,17 @@ struct AttributeGroup
|
||||||
type = "";
|
type = "";
|
||||||
remark = "";
|
remark = "";
|
||||||
isPublic = false;
|
isPublic = false;
|
||||||
|
version = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//利用移动语义优化的构造函数(不定义也可以,QString实际上实现了隐式共享)
|
//利用移动语义优化的构造函数(不定义也可以,QString实际上实现了隐式共享)
|
||||||
AttributeGroup(int id, QString name, QString type, QString remark, bool isPublic)
|
AttributeGroup(int id, QString name, QString type, QString remark, bool isPublic, int version = 0)
|
||||||
: id(id),
|
: id(id),
|
||||||
name(std::move(name)),
|
name(std::move(name)),
|
||||||
type(std::move(type)),
|
type(std::move(type)),
|
||||||
remark(std::move(remark)),
|
remark(std::move(remark)),
|
||||||
isPublic(isPublic){}
|
isPublic(isPublic),
|
||||||
|
version(version){}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Model
|
struct Model
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ private slots:
|
||||||
void onSIG_addGroups(int, QVector<int>);
|
void onSIG_addGroups(int, QVector<int>);
|
||||||
void onSIG_openAttributeInfo(const QString&, ModelAttributeGroup&);
|
void onSIG_openAttributeInfo(const QString&, ModelAttributeGroup&);
|
||||||
void onSIG_closeAttributeInfo(ModelAttributeGroup&);
|
void onSIG_closeAttributeInfo(ModelAttributeGroup&);
|
||||||
|
void onSIG_closeAllAttributeInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public:
|
||||||
~MessageDialog();
|
~MessageDialog();
|
||||||
|
|
||||||
void setType(MessageDialogType);
|
void setType(MessageDialogType);
|
||||||
void setMessage(MessageDialogType,const QString&,const QString&);
|
void setMessage(MessageDialogType, const QString&, const QString&);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sgl_hide();
|
void sgl_hide();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="img">
|
<qresource prefix="img">
|
||||||
|
<file>images/icon_hierarchy_unchecked.png</file>
|
||||||
|
<file>images/icon_hierarchy_disable.png</file>
|
||||||
<file>images/icon_search_white.png</file>
|
<file>images/icon_search_white.png</file>
|
||||||
<file>images/icon_search.png</file>
|
<file>images/icon_search.png</file>
|
||||||
<file>images/icon_refresh3_disable.png</file>
|
<file>images/icon_refresh3_disable.png</file>
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 221 B |
Binary file not shown.
|
After Width: | Height: | Size: 213 B |
|
|
@ -146,7 +146,7 @@ bool AttributeTableModel::setData(const QModelIndex &index, const QVariant &valu
|
||||||
m_currentPageData[row] = modifiedRow;
|
m_currentPageData[row] = modifiedRow;
|
||||||
|
|
||||||
emit dataChanged(index, index, {role, Qt::UserRole + AttributeEidt::EditStatus});
|
emit dataChanged(index, index, {role, Qt::UserRole + AttributeEidt::EditStatus});
|
||||||
emit syncDataStatus(m_modifiedRows.isEmpty(), m_paginationInfo);
|
emit syncDataStatus(dataHasbeenModified(), m_paginationInfo);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -408,13 +408,16 @@ int AttributeTableModel::pageSize() const
|
||||||
return m_paginationInfo.entriesPerPage;
|
return m_paginationInfo.entriesPerPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttributeTableModel::setCurrentPage(int page)
|
bool AttributeTableModel::setCurrentPage(int page)
|
||||||
{
|
{
|
||||||
if(m_paginationInfo.currentPage != page && page > 0 && page <= totalPages())
|
if(m_paginationInfo.currentPage != page && page > 0 && page <= totalPages())
|
||||||
{
|
{
|
||||||
m_paginationInfo.currentPage = page;
|
m_paginationInfo.currentPage = page;
|
||||||
refresh();
|
refresh();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
int AttributeTableModel::currentPage() const
|
int AttributeTableModel::currentPage() const
|
||||||
{
|
{
|
||||||
|
|
@ -492,10 +495,10 @@ QList<AttributeTableModel::RowData> AttributeTableModel::filterRowsByEditState(E
|
||||||
|
|
||||||
void AttributeTableModel::refresh()
|
void AttributeTableModel::refresh()
|
||||||
{
|
{
|
||||||
if(!m_modifiedRows.isEmpty())
|
if(dataHasbeenModified())
|
||||||
{
|
{
|
||||||
emit showMessage(type_question, QString::fromWCharArray(L"提示"),
|
emit showMessage(type_question, QString::fromWCharArray(L"提示"),
|
||||||
QString::fromWCharArray(L"有编辑数据还未提交,确认刷新放弃提交吗?"));
|
QString::fromWCharArray(L"有编辑数据还未提交,确认要放弃吗?"));
|
||||||
if(g_msgDlgBtn == btn_No)
|
if(g_msgDlgBtn == btn_No)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -503,7 +506,15 @@ void AttributeTableModel::refresh()
|
||||||
m_modifiedRows.clear();
|
m_modifiedRows.clear();
|
||||||
loadPageData();
|
loadPageData();
|
||||||
updateTotalCount();
|
updateTotalCount();
|
||||||
emit syncDataStatus(m_modifiedRows.isEmpty(), m_paginationInfo);
|
emit syncDataStatus(dataHasbeenModified(), m_paginationInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AttributeTableModel::forceRefresh()
|
||||||
|
{
|
||||||
|
m_modifiedRows.clear();
|
||||||
|
loadPageData();
|
||||||
|
updateTotalCount();
|
||||||
|
emit syncDataStatus(dataHasbeenModified(), m_paginationInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttributeTableModel::insertRecord(int row)
|
void AttributeTableModel::insertRecord(int row)
|
||||||
|
|
@ -643,16 +654,16 @@ void AttributeTableModel::submitChanges()
|
||||||
|
|
||||||
void AttributeTableModel::cancleChanges()
|
void AttributeTableModel::cancleChanges()
|
||||||
{
|
{
|
||||||
if(m_modifiedRows.isEmpty())
|
if(!dataHasbeenModified())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_modifiedRows.clear();
|
m_modifiedRows.clear();
|
||||||
loadPageData();
|
loadPageData();
|
||||||
updateTotalCount();
|
updateTotalCount();
|
||||||
emit syncDataStatus(m_modifiedRows.isEmpty(), m_paginationInfo);
|
emit syncDataStatus(dataHasbeenModified(), m_paginationInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttributeTableModel::triggerSyncSignal()
|
void AttributeTableModel::triggerSyncSignal()
|
||||||
{
|
{
|
||||||
emit syncDataStatus(m_modifiedRows.isEmpty(), m_paginationInfo);
|
emit syncDataStatus(dataHasbeenModified(), m_paginationInfo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#include "attributeView.h"
|
#include "attributeView.h"
|
||||||
#include "attributeTableDelegate.h"
|
#include "attributeTableDelegate.h"
|
||||||
#include "multiLineHeaderView.h"
|
#include "multiLineHeaderView.h"
|
||||||
|
//#include "sqlQueryExecutor.h"
|
||||||
|
#include "dataSyncManager.h"
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
@ -11,6 +13,9 @@ AttributeView::AttributeView(const ModelAttributeGroup& modelAttributeGroup, QWi
|
||||||
, m_attributeTable(tableName)
|
, m_attributeTable(tableName)
|
||||||
, m_modelAttributeGroup(modelAttributeGroup)
|
, m_modelAttributeGroup(modelAttributeGroup)
|
||||||
{
|
{
|
||||||
|
//需要进行数据同步,因此从PublicGroupSyncManager中统一获取数据
|
||||||
|
m_attributeGroup = DataSyncManager::instance().getGroup(m_modelAttributeGroup.groupID);
|
||||||
|
|
||||||
m_tableView = new QTableView(this);
|
m_tableView = new QTableView(this);
|
||||||
m_tableView->setStyleSheet("QTableView::item{padding-left:5px;} QTableView::item:selected{border:1px solid rgb(70,130,180);}");
|
m_tableView->setStyleSheet("QTableView::item{padding-left:5px;} QTableView::item:selected{border:1px solid rgb(70,130,180);}");
|
||||||
m_tableView->verticalHeader()->setVisible(false);
|
m_tableView->verticalHeader()->setVisible(false);
|
||||||
|
|
@ -57,5 +62,24 @@ AttributeView::~AttributeView()
|
||||||
|
|
||||||
void AttributeView::active()
|
void AttributeView::active()
|
||||||
{
|
{
|
||||||
m_attributeTableModel->triggerSyncSignal();
|
if(m_attributeGroup.isPublic && m_attributeGroup.version != DataSyncManager::instance().getGropuVersion(m_attributeGroup.id))
|
||||||
|
{
|
||||||
|
//提示强制刷新
|
||||||
|
emit showMessage(type_information, QString::fromWCharArray(L"提示"),
|
||||||
|
QString::fromWCharArray(L"该属性组为公共组,检测到数据发生更新,需要进行强制刷新"));
|
||||||
|
|
||||||
|
m_attributeTableModel->forceRefresh();
|
||||||
|
m_attributeGroup.version = DataSyncManager::instance().getGropuVersion(m_attributeGroup.id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_attributeTableModel->triggerSyncSignal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AttributeView::syncChangeRecord()
|
||||||
|
{
|
||||||
|
if(m_attributeGroup.isPublic)
|
||||||
|
{
|
||||||
|
m_attributeGroup.version++;
|
||||||
|
DataSyncManager::instance().syncGroupVersion(m_attributeGroup.id, m_attributeGroup.version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
#include "dataSyncManager.h"
|
||||||
|
#include "sqlQueryExecutor.h"
|
||||||
|
|
||||||
|
DataSyncManager& DataSyncManager::instance()
|
||||||
|
{
|
||||||
|
//采用静态局部变量的方式,静态局部变量的初始化是在第一次访问时,以后的调用不会多次初始化,并且生命周期和程序一致
|
||||||
|
static DataSyncManager instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataSyncManager::DataSyncManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
DataSyncManager::~DataSyncManager()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
void DataSyncManager::registerPublicGroup(const QString& connection)
|
||||||
|
{
|
||||||
|
m_publicGroups.clear();
|
||||||
|
const QVector<AttributeGroup> groups = SqlQueryExecutor::instance().getAttributeGroup(connection);
|
||||||
|
for(const AttributeGroup& group : groups)
|
||||||
|
{
|
||||||
|
if(group.isPublic)
|
||||||
|
m_publicGroups.insert(group.id, group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AttributeGroup DataSyncManager::getGroup(int groupID)
|
||||||
|
{
|
||||||
|
AttributeGroup group ;
|
||||||
|
if(m_publicGroups.contains(groupID))
|
||||||
|
group = m_publicGroups.value(groupID);
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataSyncManager::syncGroupVersion(int groupID, int version)
|
||||||
|
{
|
||||||
|
if(m_publicGroups.contains(groupID))
|
||||||
|
m_publicGroups[groupID].version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DataSyncManager::getGropuVersion(int groupID)
|
||||||
|
{
|
||||||
|
int version = 0;
|
||||||
|
if(m_publicGroups.contains(groupID))
|
||||||
|
version = m_publicGroups.value(groupID).version;
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "attributeView.h"
|
#include "attributeView.h"
|
||||||
#include <QTabBar>
|
#include <QTabBar>
|
||||||
|
#include <QRegularExpressionValidator>
|
||||||
|
|
||||||
DatabaseBrowser::DatabaseBrowser(QWidget *parent)
|
DatabaseBrowser::DatabaseBrowser(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
|
@ -10,6 +11,12 @@ DatabaseBrowser::DatabaseBrowser(QWidget *parent)
|
||||||
, m_pMainWindow(nullptr)
|
, m_pMainWindow(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
m_previousTabIndex = -1;
|
||||||
|
|
||||||
|
//正则表达式,只能输入数字
|
||||||
|
QRegularExpression regExp("[0-9]+");
|
||||||
|
QRegularExpressionValidator* validator = new QRegularExpressionValidator(regExp, this);
|
||||||
|
ui->lineEditPage->setValidator(validator);
|
||||||
|
|
||||||
connect(ui->tabWidget, &QTabWidget::tabCloseRequested, this, &DatabaseBrowser::onTabCloseRequested);
|
connect(ui->tabWidget, &QTabWidget::tabCloseRequested, this, &DatabaseBrowser::onTabCloseRequested);
|
||||||
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &DatabaseBrowser::onCurrentTabChanged);
|
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &DatabaseBrowser::onCurrentTabChanged);
|
||||||
|
|
@ -19,6 +26,13 @@ DatabaseBrowser::DatabaseBrowser(QWidget *parent)
|
||||||
connect(ui->btnSave, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_submitChanges);
|
connect(ui->btnSave, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_submitChanges);
|
||||||
connect(ui->btnCancle, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_cancleChanges);
|
connect(ui->btnCancle, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_cancleChanges);
|
||||||
connect(ui->btnRefresh, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_refreshData);
|
connect(ui->btnRefresh, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_refreshData);
|
||||||
|
|
||||||
|
connect(ui->btnFirstPage, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_firstPage);
|
||||||
|
connect(ui->btnPreviousPage, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_previousPage);
|
||||||
|
connect(ui->btnNextPage, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_nextPage);
|
||||||
|
connect(ui->btnLastPage, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_lastPage);
|
||||||
|
|
||||||
|
connect(ui->lineEditPage, &QLineEdit::returnPressed, this, &DatabaseBrowser::onEditingFinished_page);
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseBrowser::~DatabaseBrowser()
|
DatabaseBrowser::~DatabaseBrowser()
|
||||||
|
|
@ -53,6 +67,7 @@ void DatabaseBrowser::addTab_attribute(const QString& connection, ModelAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributeView* view = new AttributeView(attributeGroup, ui->tabWidget, connection);
|
AttributeView* view = new AttributeView(attributeGroup, ui->tabWidget, connection);
|
||||||
|
connect(view, &AttributeView::showMessage, this, &DatabaseBrowser::onShowMessage);
|
||||||
connect(view->model(), &AttributeTableModel::showMessage, this, &DatabaseBrowser::onShowMessage);
|
connect(view->model(), &AttributeTableModel::showMessage, this, &DatabaseBrowser::onShowMessage);
|
||||||
connect(view->model(), &AttributeTableModel::syncDataStatus, this, &DatabaseBrowser::onSyncDataStatus);
|
connect(view->model(), &AttributeTableModel::syncDataStatus, this, &DatabaseBrowser::onSyncDataStatus);
|
||||||
connect(view->delegate(), &AttributeTableDelegate::showMessage, this, &DatabaseBrowser::onShowMessage);
|
connect(view->delegate(), &AttributeTableDelegate::showMessage, this, &DatabaseBrowser::onShowMessage);
|
||||||
|
|
@ -90,6 +105,13 @@ void DatabaseBrowser::closeTab_attribute(ModelAttributeGroup& attributeGroup)
|
||||||
onTabCloseRequested(index);
|
onTabCloseRequested(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseBrowser::closeAllTab_attribute()
|
||||||
|
{
|
||||||
|
int tabCount = ui->tabWidget->count();
|
||||||
|
for(int index = 0; index < tabCount; index++)
|
||||||
|
onTabCloseRequested(0);
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseBrowser::onTabCloseRequested(int index)
|
void DatabaseBrowser::onTabCloseRequested(int index)
|
||||||
{
|
{
|
||||||
/*QObject* sender = QObject::sender();
|
/*QObject* sender = QObject::sender();
|
||||||
|
|
@ -105,6 +127,12 @@ void DatabaseBrowser::onTabCloseRequested(int index)
|
||||||
|
|
||||||
void DatabaseBrowser::onCurrentTabChanged(int index)
|
void DatabaseBrowser::onCurrentTabChanged(int index)
|
||||||
{
|
{
|
||||||
|
if(m_previousTabIndex != -1)
|
||||||
|
{
|
||||||
|
ui->tabWidget->setTabIcon(m_previousTabIndex, QIcon(":/img/images/icon_hierarchy_unchecked.png"));
|
||||||
|
}
|
||||||
|
m_previousTabIndex = index;
|
||||||
|
|
||||||
if(index == -1) //最后一个tab关闭时会触发
|
if(index == -1) //最后一个tab关闭时会触发
|
||||||
{
|
{
|
||||||
ui->btnAdd->setEnabled(false);
|
ui->btnAdd->setEnabled(false);
|
||||||
|
|
@ -114,11 +142,12 @@ void DatabaseBrowser::onCurrentTabChanged(int index)
|
||||||
ui->btnSave->setEnabled(false);
|
ui->btnSave->setEnabled(false);
|
||||||
ui->btnCancle->setEnabled(false);
|
ui->btnCancle->setEnabled(false);
|
||||||
ui->recordInfo->clear();
|
ui->recordInfo->clear();
|
||||||
ui->lineEdit->setEnabled(false);
|
ui->lineEditPage->setEnabled(false);
|
||||||
ui->lineEdit->setText("1");
|
ui->lineEditPage->setText("1");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->tabWidget->setTabIcon(m_previousTabIndex, QIcon(":/img/images/icon_hierarchy.png"));
|
||||||
QWidget* widget = ui->tabWidget->widget(index);
|
QWidget* widget = ui->tabWidget->widget(index);
|
||||||
AttributeView* attributeView = qobject_cast<AttributeView*>(widget);
|
AttributeView* attributeView = qobject_cast<AttributeView*>(widget);
|
||||||
if(attributeView)
|
if(attributeView)
|
||||||
|
|
@ -183,7 +212,10 @@ void DatabaseBrowser::onBtnClicked_submitChanges()
|
||||||
QTableView* view = attributeView->view();
|
QTableView* view = attributeView->view();
|
||||||
AttributeTableModel* model = attributeView->model();
|
AttributeTableModel* model = attributeView->model();
|
||||||
if(view && model)
|
if(view && model)
|
||||||
|
{
|
||||||
model->submitChanges();
|
model->submitChanges();
|
||||||
|
attributeView->syncChangeRecord();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,15 +245,84 @@ void DatabaseBrowser::onBtnClicked_refreshData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseBrowser::onBtnClicked_firstPage()
|
||||||
|
{
|
||||||
|
QWidget* widget = ui->tabWidget->currentWidget();
|
||||||
|
AttributeView* attributeView = qobject_cast<AttributeView*>(widget);
|
||||||
|
if(attributeView)
|
||||||
|
{
|
||||||
|
QTableView* view = attributeView->view();
|
||||||
|
AttributeTableModel* model = attributeView->model();
|
||||||
|
if(view && model)
|
||||||
|
model->firstPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseBrowser::onBtnClicked_previousPage()
|
||||||
|
{
|
||||||
|
QWidget* widget = ui->tabWidget->currentWidget();
|
||||||
|
AttributeView* attributeView = qobject_cast<AttributeView*>(widget);
|
||||||
|
if(attributeView)
|
||||||
|
{
|
||||||
|
QTableView* view = attributeView->view();
|
||||||
|
AttributeTableModel* model = attributeView->model();
|
||||||
|
if(view && model)
|
||||||
|
model->previousPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseBrowser::onBtnClicked_nextPage()
|
||||||
|
{
|
||||||
|
QWidget* widget = ui->tabWidget->currentWidget();
|
||||||
|
AttributeView* attributeView = qobject_cast<AttributeView*>(widget);
|
||||||
|
if(attributeView)
|
||||||
|
{
|
||||||
|
QTableView* view = attributeView->view();
|
||||||
|
AttributeTableModel* model = attributeView->model();
|
||||||
|
if(view && model)
|
||||||
|
model->nextPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseBrowser::onBtnClicked_lastPage()
|
||||||
|
{
|
||||||
|
QWidget* widget = ui->tabWidget->currentWidget();
|
||||||
|
AttributeView* attributeView = qobject_cast<AttributeView*>(widget);
|
||||||
|
if(attributeView)
|
||||||
|
{
|
||||||
|
QTableView* view = attributeView->view();
|
||||||
|
AttributeTableModel* model = attributeView->model();
|
||||||
|
if(view && model)
|
||||||
|
model->lastPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseBrowser::onEditingFinished_page()
|
||||||
|
{
|
||||||
|
QWidget* widget = ui->tabWidget->currentWidget();
|
||||||
|
AttributeView* attributeView = qobject_cast<AttributeView*>(widget);
|
||||||
|
if(attributeView)
|
||||||
|
{
|
||||||
|
QTableView* view = attributeView->view();
|
||||||
|
AttributeTableModel* model = attributeView->model();
|
||||||
|
if(view && model)
|
||||||
|
{
|
||||||
|
QString strPage = ui->lineEditPage->text();
|
||||||
|
model->setCurrentPage(strPage.toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseBrowser::onSyncDataStatus(bool hasModifiedData, const PaginationInfo& paginationInfo)
|
void DatabaseBrowser::onSyncDataStatus(bool hasModifiedData, const PaginationInfo& paginationInfo)
|
||||||
{
|
{
|
||||||
ui->btnSave->setEnabled(!hasModifiedData);
|
ui->btnSave->setEnabled(hasModifiedData);
|
||||||
ui->btnCancle->setEnabled(!hasModifiedData);
|
ui->btnCancle->setEnabled(hasModifiedData);
|
||||||
|
|
||||||
QString recordInfo = QString::fromWCharArray(L"共 %1 条记录").arg(paginationInfo.totalEntries);
|
QString recordInfo = QString::fromWCharArray(L"共 %1 条记录").arg(paginationInfo.totalEntries);
|
||||||
ui->recordInfo->setText(recordInfo);
|
ui->recordInfo->setText(recordInfo);
|
||||||
ui->lineEdit->setText(QString::number(paginationInfo.currentPage));
|
ui->lineEditPage->setText(QString::number(paginationInfo.currentPage));
|
||||||
ui->lineEdit->setEnabled(true);
|
ui->lineEditPage->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseBrowser::onShowMessage(MessageDialogType type,const QString& strTitle,const QString& strContent)
|
void DatabaseBrowser::onShowMessage(MessageDialogType type,const QString& strTitle,const QString& strContent)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "dbManager.h"
|
#include "dbManager.h"
|
||||||
#include "customMenu.h"
|
#include "customMenu.h"
|
||||||
|
#include "dataSyncManager.h"
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
@ -65,7 +66,10 @@ void DBStructureView::connectToDB(const QString& connName)
|
||||||
{
|
{
|
||||||
bool bResutl = m_dbManager->connect(connName);
|
bool bResutl = m_dbManager->connect(connName);
|
||||||
if(bResutl)
|
if(bResutl)
|
||||||
|
{
|
||||||
model->refreshStructure_Connection(connName);
|
model->refreshStructure_Connection(connName);
|
||||||
|
DataSyncManager::instance().registerPublicGroup(connName);
|
||||||
|
}
|
||||||
|
|
||||||
/*QModelIndex index = model->getConnNodeIndex(connName);
|
/*QModelIndex index = model->getConnNodeIndex(connName);
|
||||||
if(index.isValid())
|
if(index.isValid())
|
||||||
|
|
@ -86,6 +90,8 @@ void DBStructureView::disconnectToDB(const QString& connName)
|
||||||
QModelIndex index = model->getConnNodeIndex(connName);
|
QModelIndex index = model->getConnNodeIndex(connName);
|
||||||
if(index.isValid())
|
if(index.isValid())
|
||||||
collapse(index);
|
collapse(index);
|
||||||
|
|
||||||
|
emit closeAllAttributeInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ void MainWindow::initialize()
|
||||||
connect(m_pDBStrutureView, &DBStructureView::actionTrigger_addGroup, this, &MainWindow::onActionTrigger_addGroup);
|
connect(m_pDBStrutureView, &DBStructureView::actionTrigger_addGroup, this, &MainWindow::onActionTrigger_addGroup);
|
||||||
connect(m_pDBStrutureView, &DBStructureView::openAttributeInfo, this, &MainWindow::onSIG_openAttributeInfo);
|
connect(m_pDBStrutureView, &DBStructureView::openAttributeInfo, this, &MainWindow::onSIG_openAttributeInfo);
|
||||||
connect(m_pDBStrutureView, &DBStructureView::closeAttributeInfo, this, &MainWindow::onSIG_closeAttributeInfo);
|
connect(m_pDBStrutureView, &DBStructureView::closeAttributeInfo, this, &MainWindow::onSIG_closeAttributeInfo);
|
||||||
|
connect(m_pDBStrutureView, &DBStructureView::closeAllAttributeInfo, this, &MainWindow::onSIG_closeAllAttributeInfo);
|
||||||
ui->layoutDBStructure->addWidget(m_pDBStrutureView);
|
ui->layoutDBStructure->addWidget(m_pDBStrutureView);
|
||||||
m_pDBStrutureModel = new DBStructureModel(this);
|
m_pDBStrutureModel = new DBStructureModel(this);
|
||||||
m_pDBStrutureModel->setMainWindow(this);
|
m_pDBStrutureModel->setMainWindow(this);
|
||||||
|
|
@ -297,3 +298,9 @@ void MainWindow::onSIG_closeAttributeInfo(ModelAttributeGroup& attributeGroup)
|
||||||
if(m_dbBrowser)
|
if(m_dbBrowser)
|
||||||
m_dbBrowser->closeTab_attribute(attributeGroup);
|
m_dbBrowser->closeTab_attribute(attributeGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onSIG_closeAllAttributeInfo()
|
||||||
|
{
|
||||||
|
if(m_dbBrowser)
|
||||||
|
m_dbBrowser->closeAllTab_attribute();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,20 @@ void MessageDialog::setType(MessageDialogType type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageDialog::setMessage(MessageDialogType type,const QString& strTitle,const QString& strContent)
|
void MessageDialog::setMessage(MessageDialogType type, const QString& strTitle, const QString& strContent)
|
||||||
{
|
{
|
||||||
setType(type);
|
setType(type);
|
||||||
ui->labelTitle->setText(strTitle);
|
ui->labelTitle->setText(strTitle);
|
||||||
setWindowTitle(strTitle);
|
setWindowTitle(strTitle);
|
||||||
ui->labelContent->setText(strContent);
|
if(strContent.length() > 19)
|
||||||
|
{
|
||||||
|
//QString& strText = const_cast<QString&>(strContent);
|
||||||
|
QString strText(strContent);
|
||||||
|
strText.insert(19, "\n"); //实现简单自动换行
|
||||||
|
ui->labelContent->setText(strText);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ui->labelContent->setText(strContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageDialog::onBtnClicked_confirm()
|
void MessageDialog::onBtnClicked_confirm()
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ void ModelInfoEditDialog::initialize()
|
||||||
m_curModelID = -1;
|
m_curModelID = -1;
|
||||||
ui->btnAddGroup->setVisible(false);
|
ui->btnAddGroup->setVisible(false);
|
||||||
m_pMaskLayer = new MaskLayer(this);
|
m_pMaskLayer = new MaskLayer(this);
|
||||||
//正则表达式,只能属于字母
|
//正则表达式,只能输入字母
|
||||||
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->lineEdit_modelType->setValidator(validator);
|
ui->lineEdit_modelType->setValidator(validator);
|
||||||
|
|
|
||||||
|
|
@ -56,20 +56,7 @@ border-radius:3px;
|
||||||
}
|
}
|
||||||
</string>
|
</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLabel" name="label_type">
|
<widget class="QLineEdit" name="lineEdit_name">
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>20</x>
|
|
||||||
<y>10</y>
|
|
||||||
<width>61</width>
|
|
||||||
<height>16</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>属性类别:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_type">
|
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>80</x>
|
<x>80</x>
|
||||||
|
|
@ -79,20 +66,10 @@ border-radius:3px;
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit_name">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>280</x>
|
|
||||||
<y>8</y>
|
|
||||||
<width>113</width>
|
|
||||||
<height>20</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLabel" name="label_name">
|
<widget class="QLabel" name="label_name">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>220</x>
|
<x>20</x>
|
||||||
<y>10</y>
|
<y>10</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,7 @@ QPushButton:pressed
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLineEdit" name="lineEdit">
|
<widget class="QLineEdit" name="lineEditPage">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
||||||
|
|
@ -55,23 +55,24 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>50</x>
|
<x>50</x>
|
||||||
<y>23</y>
|
<y>15</y>
|
||||||
<width>261</width>
|
<width>261</width>
|
||||||
<height>20</height>
|
<height>41</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">font: 10pt;</string>
|
<string notr="true">font: 10pt;</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>该类型已存在,是否读取数据载入详细数据</string>
|
<string>该属性组为公共组,检测到数据发生更新,
|
||||||
|
需要进行强制刷新</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStackedWidget" name="stackedWidget">
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>90</x>
|
<x>90</x>
|
||||||
<y>50</y>
|
<y>53</y>
|
||||||
<width>211</width>
|
<width>211</width>
|
||||||
<height>31</height>
|
<height>31</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
|
@ -178,7 +179,7 @@ background-color:rgb(67,160,249);
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>15</y>
|
<y>18</y>
|
||||||
<width>36</width>
|
<width>36</width>
|
||||||
<height>36</height>
|
<height>36</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue