修复自定义属性编辑框通过‘esc’键关闭后,属性table会丢失焦点问题
This commit is contained in:
parent
3749f17512
commit
d791041e59
|
|
@ -45,6 +45,7 @@ set(H_HEADER_FILES
|
|||
include/customBorderContainer.h
|
||||
include/groupSelectionDialog.h
|
||||
include/dataSyncManager.h
|
||||
include/importExportManager.h
|
||||
)
|
||||
|
||||
set(CPP_SOURCE_FILES
|
||||
|
|
@ -76,6 +77,7 @@ set(CPP_SOURCE_FILES
|
|||
source/customBorderContainer.cpp
|
||||
source/groupSelectionDialog.cpp
|
||||
source/dataSyncManager.cpp
|
||||
source/importExportManager.cpp
|
||||
)
|
||||
|
||||
set(UI_FILES
|
||||
|
|
|
|||
|
|
@ -27,9 +27,11 @@ public:
|
|||
signals:
|
||||
void confirm();
|
||||
void cancle();
|
||||
void closeWidget();
|
||||
|
||||
protected:
|
||||
//bool eventFilter(QObject*, QEvent*) override;
|
||||
bool eventFilter(QObject*, QEvent*) override;
|
||||
//void closeEvent(QCloseEvent*) override;
|
||||
|
||||
private slots:
|
||||
void onTextChanged();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ TextEditWidget::TextEditWidget(QWidget* parent)
|
|||
connect(ui->plainTextEdit, &QPlainTextEdit::textChanged, this, &TextEditWidget::onTextChanged);
|
||||
connect(ui->btnConfirm, &QPushButton::clicked, this, &TextEditWidget::onBtnClicked_confirm);
|
||||
connect(ui->btnCancle, &QPushButton::clicked, this, &TextEditWidget::onBtnClicked_cancle);
|
||||
|
||||
ui->plainTextEdit->installEventFilter(this);
|
||||
}
|
||||
|
||||
TextEditWidget::~TextEditWidget()
|
||||
|
|
@ -30,19 +32,19 @@ TextEditWidget::~TextEditWidget()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
// bool TextEditWidget::eventFilter(QObject* obj, QEvent* event)
|
||||
// {
|
||||
// if (event->type() == QEvent::KeyPress)
|
||||
// {
|
||||
// QKeyEvent* pKeyEvent = static_cast<QKeyEvent*>(event);
|
||||
// if (pKeyEvent->key() == Qt::Key_Tab)
|
||||
// {
|
||||
// qDebug() << "Key_Tab";
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return QWidget::eventFilter(obj, event);
|
||||
// }
|
||||
bool TextEditWidget::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (/*obj == this && */event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent* pKeyEvent = static_cast<QKeyEvent*>(event);
|
||||
if (pKeyEvent->key() == Qt::Key_Escape)
|
||||
{
|
||||
emit closeWidget();
|
||||
//return true;
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
QString TextEditWidget::editText()
|
||||
{
|
||||
|
|
@ -207,6 +209,10 @@ QWidget* AttributeTableDelegate::createEditor(QWidget *parent, const QStyleOptio
|
|||
if(m_tableView)
|
||||
m_tableView->setFocus();
|
||||
});
|
||||
connect(textEditor, &TextEditWidget::closeWidget, this, [=]{
|
||||
if(m_tableView)
|
||||
m_tableView->setFocus();
|
||||
});
|
||||
//延迟获取焦点,防止可能因渲染未完成失效
|
||||
QTimer::singleShot(10, this, [textEditor]() {
|
||||
textEditor->setFocusToTextEdit();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ MaskManager::MaskManager(QWidget* mainWindow)
|
|||
m_maskLayer = new MaskLayer(m_mainWindow);
|
||||
// m_maskLayer->setStyleSheet("background:rgba(112,128,144,180);");
|
||||
// m_maskLayer->hide();
|
||||
m_mainWindow->installEventFilter(this); //在Qt中,时间过滤会按照install的顺序反向执行,过程中,对于同一类型事件,任何一个过滤器返回true,表示事件被处理,后续过滤器和事件函数不会再被调用
|
||||
m_mainWindow->installEventFilter(this); //在Qt中,事件过滤会按照install的顺序反向执行,过程中,对于同一类型事件,任何一个过滤器返回true,表示事件被处理,后续过滤器和事件函数不会再被调用
|
||||
}
|
||||
|
||||
bool MaskManager::eventFilter(QObject* obj, QEvent* event)
|
||||
|
|
|
|||
|
|
@ -581,8 +581,12 @@ bool SqlQueryExecutor::removeAttributeGroup(const QString& connectionName, int m
|
|||
int SqlQueryExecutor::getAttributeCount(const QString& connectionName, int modelID, int groupID)
|
||||
{
|
||||
int count = 0;
|
||||
//利用短路机制,当attribute_group_id!=-1时,括号整体为false,需要进行内部条件判断,=-1时,整体为true,忽略整体,也就忽略了attribute_group_id的条件判断
|
||||
QString strSQL = QString("SELECT COUNT(*) FROM basic.model_attribute WHERE model_type_id = %1 AND (attribute_group_id = %2 OR %2 = -1)").arg(modelID).arg(groupID);
|
||||
QString strSQL = "";
|
||||
bool isPublicGroup = isPublicAttributeGroup(connectionName, groupID);
|
||||
if(isPublicGroup)
|
||||
strSQL = QString("SELECT COUNT(*) FROM basic.model_attribute_public WHERE attribute_group_id = %1").arg(groupID);
|
||||
else
|
||||
strSQL = QString("SELECT COUNT(*) FROM basic.model_attribute WHERE model_type_id = %1 AND attribute_group_id = %2").arg(modelID).arg(groupID);
|
||||
try
|
||||
{
|
||||
QSqlQuery query = executeSQL(connectionName, strSQL);
|
||||
|
|
|
|||
Loading…
Reference in New Issue