diff --git a/src/app/qgsattributetabledialog.cpp b/src/app/qgsattributetabledialog.cpp
index 57d29f6cb04..2b0b8c582c1 100644
--- a/src/app/qgsattributetabledialog.cpp
+++ b/src/app/qgsattributetabledialog.cpp
@@ -221,9 +221,14 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
connect( mFilterActionMapper, SIGNAL( mapped( QObject * ) ), SLOT( filterColumnChanged( QObject * ) ) );
connect( mFilterQuery, &QLineEdit::returnPressed, this, &QgsAttributeTableDialog::filterQueryAccepted );
connect( mActionApplyFilter, &QAction::triggered, this, &QgsAttributeTableDialog::filterQueryAccepted );
- connect( mFilterQuery, &QLineEdit::textChanged, this, &QgsAttributeTableDialog::updateCurrentStoredFilterExpression );
+ connect( mFilterQuery, &QLineEdit::textChanged, this, &QgsAttributeTableDialog::onFilterQueryTextChanged );
connect( mActionSetStyles, &QAction::triggered, this, &QgsAttributeTableDialog::openConditionalStyles );
+ //set delay on entering text
+ mFilterQueryTimer = new QTimer( this );
+ mFilterQueryTimer->setSingleShot( true );
+ connect( mFilterQueryTimer, &QTimer::timeout, this, &QgsAttributeTableDialog::updateCurrentStoredFilterExpression );
+
// info from layer to table
connect( mLayer, &QgsVectorLayer::editingStarted, this, &QgsAttributeTableDialog::editingToggled );
connect( mLayer, &QgsVectorLayer::editingStopped, this, &QgsAttributeTableDialog::editingToggled );
@@ -506,7 +511,7 @@ void QgsAttributeTableDialog::storeExpressionButtonInit()
{
if ( mActionHandleStoreFilterExpression->isChecked() )
{
- mActionHandleStoreFilterExpression->setToolTip( tr( "Delete stored filter expression" ) );
+ mActionHandleStoreFilterExpression->setToolTip( tr( "Delete stored expression" ) );
mActionHandleStoreFilterExpression->setText( tr( "Delete Stored Expression" ) );
mActionHandleStoreFilterExpression->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionHandleStoreFilterExpressionChecked.svg" ) ) );
mStoreFilterExpressionButton->removeAction( mActionSaveAsStoredFilterExpression );
@@ -514,7 +519,7 @@ void QgsAttributeTableDialog::storeExpressionButtonInit()
}
else
{
- mActionHandleStoreFilterExpression->setToolTip( tr( "Save filter expression" ) );
+ mActionHandleStoreFilterExpression->setToolTip( tr( "Save expression with the content as name" ) );
mActionHandleStoreFilterExpression->setText( tr( "Save Expression" ) );
mActionHandleStoreFilterExpression->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionHandleStoreFilterExpressionUnchecked.svg" ) ) );
mStoreFilterExpressionButton->addAction( mActionSaveAsStoredFilterExpression );
@@ -1117,10 +1122,7 @@ void QgsAttributeTableDialog::handleStoreFilterExpression()
mLayer->storedFilterExpressions()->addStoredExpression( mFilterQuery->text(), mFilterQuery->text() );
}
- //update action id and button
- updateCurrentStoredFilterExpression( mFilterQuery->text() );
-
- //update menu list of stored filter expressions
+ updateCurrentStoredFilterExpression();
storedFilterExpressionBoxInit();
}
@@ -1135,10 +1137,7 @@ void QgsAttributeTableDialog::saveAsStoredFilterExpression()
{
mLayer->storedFilterExpressions()->addStoredExpression( nameEdit->text(), mFilterQuery->text() );
- //update action id and button
- updateCurrentStoredFilterExpression( mFilterQuery->text() );
-
- //update menu list of stored filter expressions
+ updateCurrentStoredFilterExpression();
storedFilterExpressionBoxInit();
}
}
@@ -1146,7 +1145,7 @@ void QgsAttributeTableDialog::saveAsStoredFilterExpression()
void QgsAttributeTableDialog::editStoredFilterExpression()
{
QgsDialog *dlg = new QgsDialog( this, nullptr, QDialogButtonBox::Save | QDialogButtonBox::Cancel );
- dlg->setWindowTitle( tr( "Edit expression as" ) );
+ dlg->setWindowTitle( tr( "Edit expression" ) );
QLineEdit *nameEdit = new QLineEdit( mLayer->storedFilterExpressions()->storedExpression( mActionHandleStoreFilterExpression->data().toUuid() ).name, dlg );
dlg->layout()->addWidget( nameEdit );
QLineEdit *expressionEdit = new QLineEdit( mLayer->storedFilterExpressions()->storedExpression( mActionHandleStoreFilterExpression->data().toUuid() ).expression, dlg );
@@ -1157,21 +1156,18 @@ void QgsAttributeTableDialog::editStoredFilterExpression()
//update stored expression
mLayer->storedFilterExpressions()->updateStoredExpression( mActionHandleStoreFilterExpression->data().toUuid(), nameEdit->text(), expressionEdit->text() );
- //update current expressoin
+ //update text
mFilterQuery->setValue( expressionEdit->text() );
- //update menu list of stored filter expressions
storedFilterExpressionBoxInit();
}
}
-void QgsAttributeTableDialog::updateCurrentStoredFilterExpression( const QString &value )
+void QgsAttributeTableDialog::updateCurrentStoredFilterExpression()
{
- //dave make time thingy because this is emmited on every tipe
- QgsStoredExpression currentStoredExpression = mLayer->storedFilterExpressions()->findStoredExpressionByExpression( value );
+ QgsStoredExpression currentStoredExpression = mLayer->storedFilterExpressions()->findStoredExpressionByExpression( mFilterQuery->value() );
//set checked when it's an existing stored expression
- //here it should set the button (with this action) to checked or unchecked, but this toggles blöderweise handleStoreFilterExpression dave :-/
mActionHandleStoreFilterExpression->setChecked( !currentStoredExpression.id.isNull() );
mActionHandleStoreFilterExpression->setData( currentStoredExpression.id );
@@ -1181,6 +1177,12 @@ void QgsAttributeTableDialog::updateCurrentStoredFilterExpression( const QString
storeExpressionButtonInit();
}
+void QgsAttributeTableDialog::onFilterQueryTextChanged( const QString &value )
+{
+ Q_UNUSED( value );
+ mFilterQueryTimer->start( 300 );
+}
+
void QgsAttributeTableDialog::setFilterExpression( const QString &filterString, QgsAttributeForm::FilterType type,
bool alwaysShowFilter )
{
diff --git a/src/app/qgsattributetabledialog.h b/src/app/qgsattributetabledialog.h
index 8e869ebb6af..ddcd0a94a7d 100644
--- a/src/app/qgsattributetabledialog.h
+++ b/src/app/qgsattributetabledialog.h
@@ -178,17 +178,33 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
void filterQueryChanged( const QString &query );
void filterQueryAccepted();
+ /**
+ * handle the expression (save or delete) when the bookmark button for stored
+ * filter expressions is triggered
+ */
void handleStoreFilterExpression();
+
+ /**
+ * open dialog and give the possiblity to save the expression with a name
+ */
void saveAsStoredFilterExpression();
+
+ /**
+ * open dialog and give the possiblity to edit the name and the expression
+ * of the stored expression
+ */
void editStoredFilterExpression();
/**
* updates the bookmark button and it's actions regarding the stored filter
* expressions according to the value
- *
- * @param value is usually the content of the filter query line edit widget
*/
- void updateCurrentStoredFilterExpression( const QString &value );
+ void updateCurrentStoredFilterExpression( );
+
+ /**
+ * starts timer with timeout 300 ms
+ */
+ void onFilterQueryTextChanged( const QString &value );
void openConditionalStyles();
@@ -226,7 +242,7 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
//! Initialize column box
void columnBoxInit();
- //! Initialize storedexpression box e.g after adding/deleting stored expression
+ //! Initialize storedexpression box e.g after adding/deleting/edditing stored expression
void storedFilterExpressionBoxInit();
//! Functionalities of store expression button changes regarding the status of it
void storeExpressionButtonInit();
@@ -255,6 +271,8 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
QStringList mVisibleFields;
QgsAttributeEditorContext mEditorContext;
+ QTimer *mFilterQueryTimer;
+
void updateMultiEditButtonState();
void deleteFeature( QgsFeatureId fid );
diff --git a/src/ui/qgsattributetabledialog.ui b/src/ui/qgsattributetabledialog.ui
index 4ffe101246c..1c26575a9b9 100644
--- a/src/ui/qgsattributetabledialog.ui
+++ b/src/ui/qgsattributetabledialog.ui
@@ -665,7 +665,7 @@
- :/images/themes/default/mActionFilter.svg:/images/themes/default/mActionFilter.svg
+ :/images/themes/default/mActionHandleStoreFilterExpressionChecked.svg:/images/themes/default/mActionHandleStoreFilterExpressionChecked.svg
Stored Filter Expressions
@@ -686,7 +686,7 @@
- Handle Filter Expression (save or delete)
+ Handle expression (save or delete)
@@ -710,7 +710,7 @@
Edit Expression
- Edit the expression (change name or content)
+ Edit the stored expression (change name or content)