mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
on textchange update the actions
This commit is contained in:
parent
e44b34cfc1
commit
32ebab2c9c
@ -69,6 +69,23 @@ Appends a list of expressions to the existing list
|
|||||||
%Docstring
|
%Docstring
|
||||||
Returns the list of named expressions
|
Returns the list of named expressions
|
||||||
|
|
||||||
|
:param tag: some content, maybe scope where to be shown
|
||||||
|
%End
|
||||||
|
|
||||||
|
|
||||||
|
QgsStoredExpression storedExpression( const QUuid &id, const QString &tag = QString() );
|
||||||
|
%Docstring
|
||||||
|
Returns an expression according to the id
|
||||||
|
|
||||||
|
:param id: id of the expression as identification
|
||||||
|
:param tag: some content, maybe scope where to be shown
|
||||||
|
%End
|
||||||
|
|
||||||
|
QgsStoredExpression findStoredExpressionByExpression( const QString &expression, const QString &tag = QString() );
|
||||||
|
%Docstring
|
||||||
|
Returns an expression according to the expression text
|
||||||
|
|
||||||
|
:param expression: id of the expression as identification
|
||||||
:param tag: some content, maybe scope where to be shown
|
:param tag: some content, maybe scope where to be shown
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
@ -198,6 +198,8 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
|
|||||||
// Set button to store or delete stored filter expressions
|
// Set button to store or delete stored filter expressions
|
||||||
mStoreFilterExpressionButton->setDefaultAction( mActionHandleStoreFilterExpression );
|
mStoreFilterExpressionButton->setDefaultAction( mActionHandleStoreFilterExpression );
|
||||||
connect( mActionSaveAsStoredFilterExpression, &QAction::triggered, this, &QgsAttributeTableDialog::saveAsStoredFilterExpression );
|
connect( mActionSaveAsStoredFilterExpression, &QAction::triggered, this, &QgsAttributeTableDialog::saveAsStoredFilterExpression );
|
||||||
|
connect( mActionEditStoredFilterExpression, &QAction::triggered, this, &QgsAttributeTableDialog::editStoredFilterExpression );
|
||||||
|
connect( mActionHandleStoreFilterExpression, &QAction::toggled, this, &QgsAttributeTableDialog::handleStoreFilterExpression );
|
||||||
mApplyFilterButton->setDefaultAction( mActionApplyFilter );
|
mApplyFilterButton->setDefaultAction( mActionApplyFilter );
|
||||||
|
|
||||||
mActionFeatureActions = new QToolButton();
|
mActionFeatureActions = new QToolButton();
|
||||||
@ -218,7 +220,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
|
|||||||
connect( mFilterActionMapper, SIGNAL( mapped( QObject * ) ), SLOT( filterColumnChanged( QObject * ) ) );
|
connect( mFilterActionMapper, SIGNAL( mapped( QObject * ) ), SLOT( filterColumnChanged( QObject * ) ) );
|
||||||
connect( mFilterQuery, &QLineEdit::returnPressed, this, &QgsAttributeTableDialog::filterQueryAccepted );
|
connect( mFilterQuery, &QLineEdit::returnPressed, this, &QgsAttributeTableDialog::filterQueryAccepted );
|
||||||
connect( mActionApplyFilter, &QAction::triggered, this, &QgsAttributeTableDialog::filterQueryAccepted );
|
connect( mActionApplyFilter, &QAction::triggered, this, &QgsAttributeTableDialog::filterQueryAccepted );
|
||||||
connect( mActionHandleStoreFilterExpression, &QAction::toggled, this, &QgsAttributeTableDialog::handleStoreFilterExpression );
|
connect( mFilterQuery, &QLineEdit::textChanged, this, &QgsAttributeTableDialog::updateCurrentStoredFilterExpression );
|
||||||
connect( mActionSetStyles, &QAction::triggered, this, &QgsAttributeTableDialog::openConditionalStyles );
|
connect( mActionSetStyles, &QAction::triggered, this, &QgsAttributeTableDialog::openConditionalStyles );
|
||||||
|
|
||||||
// info from layer to table
|
// info from layer to table
|
||||||
@ -507,6 +509,7 @@ void QgsAttributeTableDialog::storeExpressionButtonInit()
|
|||||||
mActionHandleStoreFilterExpression->setText( tr( "Delete Stored Expression" ) );
|
mActionHandleStoreFilterExpression->setText( tr( "Delete Stored Expression" ) );
|
||||||
mActionHandleStoreFilterExpression->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionHandleStoreFilterExpressionChecked.svg" ) ) );
|
mActionHandleStoreFilterExpression->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionHandleStoreFilterExpressionChecked.svg" ) ) );
|
||||||
mStoreFilterExpressionButton->removeAction( mActionSaveAsStoredFilterExpression );
|
mStoreFilterExpressionButton->removeAction( mActionSaveAsStoredFilterExpression );
|
||||||
|
mStoreFilterExpressionButton->addAction( mActionEditStoredFilterExpression );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -514,6 +517,7 @@ void QgsAttributeTableDialog::storeExpressionButtonInit()
|
|||||||
mActionHandleStoreFilterExpression->setText( tr( "Save Expression" ) );
|
mActionHandleStoreFilterExpression->setText( tr( "Save Expression" ) );
|
||||||
mActionHandleStoreFilterExpression->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionHandleStoreFilterExpressionUnchecked.svg" ) ) );
|
mActionHandleStoreFilterExpression->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionHandleStoreFilterExpressionUnchecked.svg" ) ) );
|
||||||
mStoreFilterExpressionButton->addAction( mActionSaveAsStoredFilterExpression );
|
mStoreFilterExpressionButton->addAction( mActionSaveAsStoredFilterExpression );
|
||||||
|
mStoreFilterExpressionButton->removeAction( mActionEditStoredFilterExpression );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1127,7 +1131,7 @@ void QgsAttributeTableDialog::handleStoreFilterExpression()
|
|||||||
if ( !mActionHandleStoreFilterExpression->isChecked() )
|
if ( !mActionHandleStoreFilterExpression->isChecked() )
|
||||||
{
|
{
|
||||||
//care for deleting by name
|
//care for deleting by name
|
||||||
mLayer->storedExpressions()->removeStoredExpression( mFilterQuery->text() );
|
mLayer->storedExpressions()->removeStoredExpression( mActionHandleStoreFilterExpression->data().toUuid() );
|
||||||
qDebug() << "changed to unchecked, here we would delete it...";
|
qDebug() << "changed to unchecked, here we would delete it...";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1140,6 +1144,22 @@ void QgsAttributeTableDialog::handleStoreFilterExpression()
|
|||||||
storedFilterExpressionBoxInit();
|
storedFilterExpressionBoxInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsAttributeTableDialog::updateCurrentStoredFilterExpression( const QString &value )
|
||||||
|
{
|
||||||
|
//dave make time thingy because this is emmited on every tipe
|
||||||
|
QgsStoredExpression currentStoredExpression = mLayer->storedExpressions()->findStoredExpressionByExpression( value );
|
||||||
|
if ( !currentStoredExpression.id.isNull() )
|
||||||
|
{
|
||||||
|
mActionHandleStoreFilterExpression->setChecked( true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mActionHandleStoreFilterExpression->setChecked( false );
|
||||||
|
}
|
||||||
|
mActionHandleStoreFilterExpression->setData( currentStoredExpression.id );
|
||||||
|
mActionEditStoredFilterExpression->setData( currentStoredExpression.id );
|
||||||
|
}
|
||||||
|
|
||||||
void QgsAttributeTableDialog::setFilterExpression( const QString &filterString, QgsAttributeForm::FilterType type,
|
void QgsAttributeTableDialog::setFilterExpression( const QString &filterString, QgsAttributeForm::FilterType type,
|
||||||
bool alwaysShowFilter )
|
bool alwaysShowFilter )
|
||||||
{
|
{
|
||||||
|
@ -182,6 +182,7 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
|
|||||||
void saveAsStoredFilterExpression();
|
void saveAsStoredFilterExpression();
|
||||||
void editStoredFilterExpression();
|
void editStoredFilterExpression();
|
||||||
void handleStoreFilterExpression();
|
void handleStoreFilterExpression();
|
||||||
|
void updateCurrentStoredFilterExpression( const QString &value );
|
||||||
|
|
||||||
void openConditionalStyles();
|
void openConditionalStyles();
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ QUuid QgsStoredExpressionManager::addStoredExpression( const QString &name, cons
|
|||||||
|
|
||||||
QgsStoredExpression storedExpression; //( name, expression );
|
QgsStoredExpression storedExpression; //( name, expression );
|
||||||
|
|
||||||
|
storedExpression.id = QUuid::createUuid();
|
||||||
storedExpression.name = name;
|
storedExpression.name = name;
|
||||||
storedExpression.expression = expression;
|
storedExpression.expression = expression;
|
||||||
|
|
||||||
@ -69,6 +70,34 @@ QList< QgsStoredExpression > QgsStoredExpressionManager::storedExpressions( cons
|
|||||||
return mStoredExpressions;
|
return mStoredExpressions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QgsStoredExpression QgsStoredExpressionManager::storedExpression( const QUuid &id, const QString &tag )
|
||||||
|
{
|
||||||
|
Q_UNUSED( tag );
|
||||||
|
|
||||||
|
for ( const QgsStoredExpression &storedExpression : mStoredExpressions )
|
||||||
|
{
|
||||||
|
if ( storedExpression.id == id )
|
||||||
|
{
|
||||||
|
return storedExpression;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QgsStoredExpression();
|
||||||
|
}
|
||||||
|
|
||||||
|
QgsStoredExpression QgsStoredExpressionManager::findStoredExpressionByExpression( const QString &expression, const QString &tag )
|
||||||
|
{
|
||||||
|
Q_UNUSED( tag );
|
||||||
|
|
||||||
|
for ( const QgsStoredExpression &storedExpression : mStoredExpressions )
|
||||||
|
{
|
||||||
|
if ( storedExpression.expression == expression )
|
||||||
|
{
|
||||||
|
return storedExpression;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QgsStoredExpression();
|
||||||
|
}
|
||||||
|
|
||||||
void QgsStoredExpressionManager::clearStoredExpressions()
|
void QgsStoredExpressionManager::clearStoredExpressions()
|
||||||
{
|
{
|
||||||
mStoredExpressions.clear();
|
mStoredExpressions.clear();
|
||||||
|
@ -106,6 +106,23 @@ class CORE_EXPORT QgsStoredExpressionManager : public QObject
|
|||||||
*/
|
*/
|
||||||
QList< QgsStoredExpression > storedExpressions( const QString &tag = QString() );
|
QList< QgsStoredExpression > storedExpressions( const QString &tag = QString() );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an expression according to the id
|
||||||
|
*
|
||||||
|
* \param id id of the expression as identification
|
||||||
|
* \param tag some content, maybe scope where to be shown
|
||||||
|
*/
|
||||||
|
QgsStoredExpression storedExpression( const QUuid &id, const QString &tag = QString() );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an expression according to the expression text
|
||||||
|
*
|
||||||
|
* \param expression id of the expression as identification
|
||||||
|
* \param tag some content, maybe scope where to be shown
|
||||||
|
*/
|
||||||
|
QgsStoredExpression findStoredExpressionByExpression( const QString &expression, const QString &tag = QString() );
|
||||||
|
|
||||||
//! clears list of stored expressions
|
//! clears list of stored expressions
|
||||||
void clearStoredExpressions();
|
void clearStoredExpressions();
|
||||||
|
|
||||||
|
@ -701,6 +701,18 @@
|
|||||||
<string>Save expression under defined name</string>
|
<string>Save expression under defined name</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="mActionEditStoredFilterExpression">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../images/images.qrc">
|
||||||
|
<normaloff>:/images/themes/default/mActionHandleStoreFilterExpressionChecked.svg</normaloff>:/images/themes/default/mActionHandleStoreFilterExpressionChecked.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Edit Expression</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Edit the expression (change name or content)</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user