mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-08 00:02:35 -05:00
wait 300 ms before update stored expression button after text changed on filter query line edit
more comments and clean up
This commit is contained in:
parent
1c44192929
commit
4813ade649
@ -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 )
|
||||
{
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -665,7 +665,7 @@
|
||||
<action name="mActionStoredFilterExpressions">
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mActionFilter.svg</normaloff>:/images/themes/default/mActionFilter.svg</iconset>
|
||||
<normaloff>:/images/themes/default/mActionHandleStoreFilterExpressionChecked.svg</normaloff>:/images/themes/default/mActionHandleStoreFilterExpressionChecked.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stored Filter Expressions</string>
|
||||
@ -686,7 +686,7 @@
|
||||
<string/>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Handle Filter Expression (save or delete)</string>
|
||||
<string>Handle expression (save or delete)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionSaveAsStoredFilterExpression">
|
||||
@ -710,7 +710,7 @@
|
||||
<string>Edit Expression</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Edit the expression (change name or content)</string>
|
||||
<string>Edit the stored expression (change name or content)</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
Loading…
x
Reference in New Issue
Block a user