2025-03-18 18:35:30 +08:00
|
|
|
|
#include "dbBrowser.h"
|
|
|
|
|
|
#include "ui_dbBrowser.h"
|
2025-03-26 15:57:08 +08:00
|
|
|
|
#include "mainwindow.h"
|
2025-03-24 18:13:06 +08:00
|
|
|
|
#include "attributeView.h"
|
|
|
|
|
|
#include <QTabBar>
|
2025-04-25 11:49:03 +08:00
|
|
|
|
#include <QRegularExpressionValidator>
|
2025-05-19 11:04:46 +08:00
|
|
|
|
#include <QKeyEvent>
|
2025-03-18 18:35:30 +08:00
|
|
|
|
|
|
|
|
|
|
DatabaseBrowser::DatabaseBrowser(QWidget *parent)
|
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
|
, ui(new Ui::DatabaseBrowser)
|
2025-03-26 15:57:08 +08:00
|
|
|
|
, m_pMainWindow(nullptr)
|
2025-03-18 18:35:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
2025-04-25 11:49:03 +08:00
|
|
|
|
m_previousTabIndex = -1;
|
|
|
|
|
|
|
|
|
|
|
|
//正则表达式,只能输入数字
|
|
|
|
|
|
QRegularExpression regExp("[0-9]+");
|
|
|
|
|
|
QRegularExpressionValidator* validator = new QRegularExpressionValidator(regExp, this);
|
|
|
|
|
|
ui->lineEditPage->setValidator(validator);
|
2025-05-19 11:04:46 +08:00
|
|
|
|
ui->lineEditPage->installEventFilter(this);
|
2025-03-24 19:55:01 +08:00
|
|
|
|
|
2025-03-25 17:58:48 +08:00
|
|
|
|
connect(ui->tabWidget, &QTabWidget::tabCloseRequested, this, &DatabaseBrowser::onTabCloseRequested);
|
|
|
|
|
|
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &DatabaseBrowser::onCurrentTabChanged);
|
2025-03-27 21:01:25 +08:00
|
|
|
|
|
2025-04-29 17:54:44 +08:00
|
|
|
|
connect(ui->btnSelect, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_selectRecord);
|
2025-03-27 21:01:25 +08:00
|
|
|
|
connect(ui->btnAdd, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_addRecord);
|
|
|
|
|
|
connect(ui->btnRemove, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_removeRecord);
|
2025-04-01 14:37:41 +08:00
|
|
|
|
connect(ui->btnSave, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_submitChanges);
|
2025-04-02 15:57:00 +08:00
|
|
|
|
connect(ui->btnCancle, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_cancleChanges);
|
|
|
|
|
|
connect(ui->btnRefresh, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClicked_refreshData);
|
2025-04-25 11:49:03 +08:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
2025-05-19 11:04:46 +08:00
|
|
|
|
//editingFinished在输入的内容为空时不会触发,所以改为在eventFilter中实现
|
|
|
|
|
|
connect(ui->lineEditPage, &QLineEdit::editingFinished, this, &DatabaseBrowser::onEditingFinished_page);
|
2025-03-18 18:35:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DatabaseBrowser::~DatabaseBrowser()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
2025-03-24 18:13:06 +08:00
|
|
|
|
|
2025-05-19 11:04:46 +08:00
|
|
|
|
bool DatabaseBrowser::eventFilter(QObject* obj, QEvent* event)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(obj == ui->lineEditPage)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(event->type() == QEvent::KeyPress)
|
|
|
|
|
|
{
|
|
|
|
|
|
QKeyEvent* pKeyEvent = static_cast<QKeyEvent*>(event);
|
|
|
|
|
|
if (pKeyEvent->key() == Qt::Key_Enter || pKeyEvent->key() == Qt::Key_Return)
|
|
|
|
|
|
{
|
|
|
|
|
|
onEditingFinished_page();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(event->type() == QEvent::FocusOut)
|
|
|
|
|
|
onEditingFinished_page();
|
|
|
|
|
|
}
|
|
|
|
|
|
return QWidget::eventFilter(obj, event);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-26 15:57:08 +08:00
|
|
|
|
void DatabaseBrowser::setMainWindow(MainWindow* window)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pMainWindow = window;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-24 19:55:01 +08:00
|
|
|
|
int DatabaseBrowser::tabIndex(const QString& tabText)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(int i = 0; i < ui->tabWidget->count(); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(ui->tabWidget->tabText(i) == tabText)
|
|
|
|
|
|
return i;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-24 18:13:06 +08:00
|
|
|
|
void DatabaseBrowser::addTab_attribute(const QString& connection, ModelAttributeGroup& attributeGroup)
|
|
|
|
|
|
{
|
2025-03-24 19:55:01 +08:00
|
|
|
|
QString tabText = attributeGroup.strModelName + "/" + attributeGroup.strGroupName;
|
|
|
|
|
|
int index = tabIndex(tabText);
|
|
|
|
|
|
if(index != -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->tabWidget->setCurrentIndex(index);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-25 17:58:48 +08:00
|
|
|
|
AttributeView* view = new AttributeView(attributeGroup, ui->tabWidget, connection);
|
2025-04-25 11:49:03 +08:00
|
|
|
|
connect(view, &AttributeView::showMessage, this, &DatabaseBrowser::onShowMessage);
|
2025-03-26 15:57:08 +08:00
|
|
|
|
connect(view->model(), &AttributeTableModel::showMessage, this, &DatabaseBrowser::onShowMessage);
|
2025-03-25 20:53:15 +08:00
|
|
|
|
connect(view->model(), &AttributeTableModel::syncDataStatus, this, &DatabaseBrowser::onSyncDataStatus);
|
2025-04-11 17:14:17 +08:00
|
|
|
|
connect(view->delegate(), &AttributeTableDelegate::showMessage, this, &DatabaseBrowser::onShowMessage);
|
2025-03-24 19:55:01 +08:00
|
|
|
|
index = ui->tabWidget->addTab(view, QIcon(":/img/images/icon_hierarchy.png"), tabText);
|
2025-05-16 18:42:59 +08:00
|
|
|
|
if(view->model())
|
|
|
|
|
|
view->model()->refresh();
|
2025-03-24 18:13:06 +08:00
|
|
|
|
//添加自定义按钮
|
2025-03-24 19:55:01 +08:00
|
|
|
|
/*QPushButton* closeBtn = new QPushButton("");
|
|
|
|
|
|
closeBtn->setProperty("index", index);
|
|
|
|
|
|
connect(closeBtn, &QPushButton::clicked, this, &DatabaseBrowser::onBtnClick_tabCloseBtn);
|
2025-03-24 18:13:06 +08:00
|
|
|
|
closeBtn->setFixedSize(12, 12);
|
|
|
|
|
|
closeBtn->setStyleSheet("QPushButton\n"
|
|
|
|
|
|
"{\n"
|
|
|
|
|
|
" border-image: url(:/img/images/btn_close_default.png);\n"
|
|
|
|
|
|
"}\n"
|
|
|
|
|
|
"QPushButton:hover\n"
|
|
|
|
|
|
"{\n"
|
|
|
|
|
|
" border-image: url(:/img/images/btn_close_hover.png);\n"
|
|
|
|
|
|
"}\n"
|
|
|
|
|
|
"QPushButton:pressed\n"
|
|
|
|
|
|
"{\n"
|
|
|
|
|
|
" border-image: url(:/img/images/btn_close_pressed.png);\n"
|
|
|
|
|
|
"}");
|
|
|
|
|
|
QTabBar* tabBar = ui->tabWidget->tabBar();
|
2025-03-24 19:55:01 +08:00
|
|
|
|
tabBar->setTabButton(index, QTabBar::RightSide, closeBtn);*/
|
2025-03-24 18:13:06 +08:00
|
|
|
|
|
|
|
|
|
|
ui->tabWidget->setCurrentIndex(index);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-17 15:34:43 +08:00
|
|
|
|
void DatabaseBrowser::closeTab_attribute(ModelAttributeGroup& attributeGroup)
|
|
|
|
|
|
{
|
2025-04-28 14:25:45 +08:00
|
|
|
|
if(attributeGroup.groupID == -1) //关闭该模型下所有打开的tab
|
|
|
|
|
|
{
|
|
|
|
|
|
//int tabCount = ui->tabWidget->count();
|
|
|
|
|
|
for(int i = 0; i < ui->tabWidget->count(); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(ui->tabWidget->tabText(i).contains(attributeGroup.strModelName + "/"))
|
|
|
|
|
|
{
|
|
|
|
|
|
onTabCloseRequested(i);
|
|
|
|
|
|
i--;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-04-17 15:34:43 +08:00
|
|
|
|
|
2025-04-28 14:25:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
else //关闭具体的tab
|
|
|
|
|
|
{
|
|
|
|
|
|
QString tabText = attributeGroup.strModelName + "/" + attributeGroup.strGroupName;
|
|
|
|
|
|
int index = tabIndex(tabText);
|
|
|
|
|
|
if(index == -1)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
onTabCloseRequested(index);
|
|
|
|
|
|
}
|
2025-04-17 15:34:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-25 11:49:03 +08:00
|
|
|
|
void DatabaseBrowser::closeAllTab_attribute()
|
|
|
|
|
|
{
|
|
|
|
|
|
int tabCount = ui->tabWidget->count();
|
|
|
|
|
|
for(int index = 0; index < tabCount; index++)
|
|
|
|
|
|
onTabCloseRequested(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-25 17:58:48 +08:00
|
|
|
|
void DatabaseBrowser::onTabCloseRequested(int index)
|
2025-03-24 18:13:06 +08:00
|
|
|
|
{
|
2025-03-24 19:55:01 +08:00
|
|
|
|
/*QObject* sender = QObject::sender();
|
|
|
|
|
|
QPushButton* button = qobject_cast<QPushButton*>(sender);
|
|
|
|
|
|
if(!button)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
int index = button->property("index").toInt();*/
|
|
|
|
|
|
QWidget* widget = ui->tabWidget->widget(index);
|
|
|
|
|
|
ui->tabWidget->removeTab(index);
|
|
|
|
|
|
delete widget;
|
2025-03-24 18:13:06 +08:00
|
|
|
|
}
|
2025-03-25 17:58:48 +08:00
|
|
|
|
|
|
|
|
|
|
void DatabaseBrowser::onCurrentTabChanged(int index)
|
|
|
|
|
|
{
|
2025-04-25 11:49:03 +08:00
|
|
|
|
if(m_previousTabIndex != -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->tabWidget->setTabIcon(m_previousTabIndex, QIcon(":/img/images/icon_hierarchy_unchecked.png"));
|
|
|
|
|
|
}
|
|
|
|
|
|
m_previousTabIndex = index;
|
|
|
|
|
|
|
2025-03-25 17:58:48 +08:00
|
|
|
|
if(index == -1) //最后一个tab关闭时会触发
|
|
|
|
|
|
{
|
2025-04-29 17:54:44 +08:00
|
|
|
|
ui->btnSelect->setEnabled(false);
|
2025-03-25 20:53:15 +08:00
|
|
|
|
ui->btnAdd->setEnabled(false);
|
|
|
|
|
|
ui->btnRemove->setEnabled(false);
|
|
|
|
|
|
ui->btnCancle->setEnabled(false);
|
|
|
|
|
|
ui->btnRefresh->setEnabled(false);
|
|
|
|
|
|
ui->btnSave->setEnabled(false);
|
|
|
|
|
|
ui->btnCancle->setEnabled(false);
|
2025-04-25 16:44:32 +08:00
|
|
|
|
|
|
|
|
|
|
ui->btnFirstPage->setEnabled(false);
|
|
|
|
|
|
ui->btnPreviousPage->setEnabled(false);
|
|
|
|
|
|
ui->btnNextPage->setEnabled(false);
|
|
|
|
|
|
ui->btnLastPage->setEnabled(false);
|
2025-03-25 17:58:48 +08:00
|
|
|
|
ui->recordInfo->clear();
|
2025-04-25 11:49:03 +08:00
|
|
|
|
ui->lineEditPage->setEnabled(false);
|
|
|
|
|
|
ui->lineEditPage->setText("1");
|
2025-03-25 17:58:48 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-25 11:49:03 +08:00
|
|
|
|
ui->tabWidget->setTabIcon(m_previousTabIndex, QIcon(":/img/images/icon_hierarchy.png"));
|
2025-03-25 17:58:48 +08:00
|
|
|
|
QWidget* widget = ui->tabWidget->widget(index);
|
|
|
|
|
|
AttributeView* attributeView = qobject_cast<AttributeView*>(widget);
|
|
|
|
|
|
if(attributeView)
|
|
|
|
|
|
{
|
2025-04-29 17:54:44 +08:00
|
|
|
|
ui->btnSelect->setEnabled(true);
|
2025-03-25 20:53:15 +08:00
|
|
|
|
ui->btnAdd->setEnabled(true);
|
|
|
|
|
|
ui->btnRemove->setEnabled(true);
|
|
|
|
|
|
ui->btnCancle->setEnabled(true);
|
|
|
|
|
|
ui->btnRefresh->setEnabled(true);
|
2025-04-25 16:44:32 +08:00
|
|
|
|
|
|
|
|
|
|
ui->btnFirstPage->setEnabled(true);
|
|
|
|
|
|
ui->btnPreviousPage->setEnabled(true);
|
|
|
|
|
|
ui->btnNextPage->setEnabled(true);
|
|
|
|
|
|
ui->btnLastPage->setEnabled(true);
|
|
|
|
|
|
ui->lineEditPage->setEnabled(true);
|
|
|
|
|
|
|
2025-03-25 17:58:48 +08:00
|
|
|
|
attributeView->active();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-25 20:53:15 +08:00
|
|
|
|
|
2025-04-29 17:54:44 +08:00
|
|
|
|
void DatabaseBrowser::onBtnClicked_selectRecord()
|
|
|
|
|
|
{
|
|
|
|
|
|
emit openAttributeSelector();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-27 21:01:25 +08:00
|
|
|
|
void DatabaseBrowser::onBtnClicked_addRecord()
|
|
|
|
|
|
{
|
|
|
|
|
|
QWidget* widget = ui->tabWidget->currentWidget();
|
|
|
|
|
|
AttributeView* attributeView = qobject_cast<AttributeView*>(widget);
|
|
|
|
|
|
if(attributeView)
|
|
|
|
|
|
{
|
|
|
|
|
|
QTableView* view = attributeView->view();
|
|
|
|
|
|
AttributeTableModel* model = attributeView->model();
|
|
|
|
|
|
if(view && model)
|
|
|
|
|
|
{
|
|
|
|
|
|
int row = model->rowCount(); //当前插入都是在最后一行
|
|
|
|
|
|
/*QModelIndex currentIndex = view->currentIndex();
|
|
|
|
|
|
if(currentIndex.row() != -1)
|
|
|
|
|
|
row = currentIndex.row();*/
|
|
|
|
|
|
model->insertRecord(row);
|
2025-04-01 14:37:41 +08:00
|
|
|
|
ui->btnSave->setEnabled(true);
|
|
|
|
|
|
ui->btnCancle->setEnabled(true);
|
2025-03-27 21:01:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DatabaseBrowser::onBtnClicked_removeRecord()
|
|
|
|
|
|
{
|
|
|
|
|
|
QWidget* widget = ui->tabWidget->currentWidget();
|
|
|
|
|
|
AttributeView* attributeView = qobject_cast<AttributeView*>(widget);
|
|
|
|
|
|
if(attributeView)
|
|
|
|
|
|
{
|
|
|
|
|
|
QTableView* view = attributeView->view();
|
|
|
|
|
|
AttributeTableModel* model = attributeView->model();
|
|
|
|
|
|
if(view && model)
|
|
|
|
|
|
{
|
2025-04-29 17:54:44 +08:00
|
|
|
|
/*QModelIndex currentIndex = view->currentIndex();
|
2025-03-27 21:01:25 +08:00
|
|
|
|
int row = currentIndex.row();
|
|
|
|
|
|
if( row != -1)
|
2025-04-01 14:37:41 +08:00
|
|
|
|
{
|
2025-03-27 21:01:25 +08:00
|
|
|
|
model->removeRecord(row);
|
2025-04-01 14:37:41 +08:00
|
|
|
|
ui->btnSave->setEnabled(true);
|
|
|
|
|
|
ui->btnCancle->setEnabled(true);
|
2025-04-29 17:54:44 +08:00
|
|
|
|
}*/
|
|
|
|
|
|
model->removeRecord();
|
|
|
|
|
|
ui->btnSave->setEnabled(true);
|
|
|
|
|
|
ui->btnCancle->setEnabled(true);
|
2025-03-27 21:01:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-01 14:37:41 +08:00
|
|
|
|
void DatabaseBrowser::onBtnClicked_submitChanges()
|
|
|
|
|
|
{
|
|
|
|
|
|
QWidget* widget = ui->tabWidget->currentWidget();
|
|
|
|
|
|
AttributeView* attributeView = qobject_cast<AttributeView*>(widget);
|
|
|
|
|
|
if(attributeView)
|
|
|
|
|
|
{
|
|
|
|
|
|
QTableView* view = attributeView->view();
|
|
|
|
|
|
AttributeTableModel* model = attributeView->model();
|
|
|
|
|
|
if(view && model)
|
2025-04-25 11:49:03 +08:00
|
|
|
|
{
|
2025-04-01 14:37:41 +08:00
|
|
|
|
model->submitChanges();
|
2025-04-25 11:49:03 +08:00
|
|
|
|
attributeView->syncChangeRecord();
|
|
|
|
|
|
}
|
2025-04-01 14:37:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-02 15:57:00 +08:00
|
|
|
|
void DatabaseBrowser::onBtnClicked_cancleChanges()
|
|
|
|
|
|
{
|
|
|
|
|
|
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->cancleChanges();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DatabaseBrowser::onBtnClicked_refreshData()
|
|
|
|
|
|
{
|
|
|
|
|
|
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->refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-25 11:49:03 +08:00
|
|
|
|
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();
|
2025-04-25 16:44:32 +08:00
|
|
|
|
bool result = model->setCurrentPage(strPage.toInt());
|
|
|
|
|
|
if(!result)
|
|
|
|
|
|
ui->lineEditPage->setText(QString::number(model->currentPage()));
|
2025-04-25 11:49:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-25 20:53:15 +08:00
|
|
|
|
void DatabaseBrowser::onSyncDataStatus(bool hasModifiedData, const PaginationInfo& paginationInfo)
|
|
|
|
|
|
{
|
2025-04-25 11:49:03 +08:00
|
|
|
|
ui->btnSave->setEnabled(hasModifiedData);
|
|
|
|
|
|
ui->btnCancle->setEnabled(hasModifiedData);
|
2025-03-25 20:53:15 +08:00
|
|
|
|
|
|
|
|
|
|
QString recordInfo = QString::fromWCharArray(L"共 %1 条记录").arg(paginationInfo.totalEntries);
|
|
|
|
|
|
ui->recordInfo->setText(recordInfo);
|
2025-04-25 11:49:03 +08:00
|
|
|
|
ui->lineEditPage->setText(QString::number(paginationInfo.currentPage));
|
2025-03-25 20:53:15 +08:00
|
|
|
|
}
|
2025-03-26 15:57:08 +08:00
|
|
|
|
|
|
|
|
|
|
void DatabaseBrowser::onShowMessage(MessageDialogType type,const QString& strTitle,const QString& strContent)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_pMainWindow)
|
|
|
|
|
|
m_pMainWindow->showMessageDialog(type, strTitle, strContent);
|
|
|
|
|
|
}
|
2025-05-08 09:30:47 +08:00
|
|
|
|
|
|
|
|
|
|
void DatabaseBrowser::processAttributeSelectedData(QVector<QVector<QVariant>> datas)
|
|
|
|
|
|
{
|
|
|
|
|
|
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->addRecords(datas);
|
|
|
|
|
|
ui->btnSave->setEnabled(true);
|
|
|
|
|
|
ui->btnCancle->setEnabled(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|