26#include "moc_qgssmartgroupeditordialog.cpp"
28using namespace Qt::StringLiterals;
40 mCondCombo->addItem( tr(
"has the tag" ), QVariant(
"tag" ) );
41 mCondCombo->addItem( tr(
"has a part of name matching" ), QVariant(
"name" ) );
42 mCondCombo->addItem( tr(
"does NOT have the tag" ), QVariant(
"!tag" ) );
43 mCondCombo->addItem( tr(
"has NO part of name matching" ), QVariant(
"!name" ) );
57 return mCondCombo->currentData().toString();
62 return mCondLineEdit->text();
67 mCondCombo->setCurrentIndex( mCondCombo->findData( QVariant(
constraint ) ) );
72 mCondLineEdit->setText( param );
77 mRemoveBtn->setVisible( !hide );
91 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QgsSmartGroupEditorDialog::buttonBox_accepted );
95 mAndOrCombo->addItem( tr(
"ALL the constraints" ), QVariant(
"AND" ) );
96 mAndOrCombo->addItem( tr(
"any ONE of the constraints" ), QVariant(
"OR" ) );
98 mLayout =
new QGridLayout( mConditionsBox );
106 return mNameLineEdit->text();
117 condition->hideRemoveButton(
false );
140 condition->hideRemoveButton(
true );
155 conditions.insert( condition->constraint(), condition->parameter() );
163 return mAndOrCombo->currentData().toString();
168 QStringList constraints;
169 constraints << u
"tag"_s << u
"name"_s << u
"!tag"_s << u
"!name"_s;
176 const auto constConstraints = constraints;
177 for (
const QString &constr : constConstraints )
179 const QStringList params = map.values( constr );
180 const auto constParams = params;
181 for (
const QString ¶m : constParams )
199 mAndOrCombo->setCurrentIndex( mAndOrCombo->findData( QVariant( op ) ) );
204 mNameLineEdit->setText( name );
207void QgsSmartGroupEditorDialog::buttonBox_accepted()
209 if ( mNameLineEdit->text().isEmpty() )
211 QMessageBox::critical(
this, tr(
"Edit Smart Group" ), tr(
"The smart group name field is empty. Kindly provide a name." ) );
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
A widget for configuring the conditions attached to a style smart group.
void setConstraint(const QString &constraint)
sets the given constraint
QgsSmartGroupCondition(int id, QWidget *parent=nullptr)
QString parameter()
returns the parameter
void setParameter(const QString ¶m)
sets the given param
void removed(int id)
Emitted when the group with the specified id is removed.
void hideRemoveButton(bool hide)
sets the remove button hidden state to 'hide'
QString constraint()
returns the constraint key
void setConditionMap(const QgsSmartConditionMap &)
sets up the GUI for the given conditionmap
QMap< int, QgsSmartGroupCondition * > mConditionMap
QgsSmartConditionMap conditionMap()
returns the condition map
QString smartgroupName()
returns the value from mNameLineEdit
QgsSmartGroupEditorDialog(QgsStyle *style, QWidget *parent=nullptr)
void addCondition()
function to create a new ConditionBox and update UI
void removeCondition(int)
slot to remove the condition with id int
void setSmartgroupName(const QString &)
sets the smart group Name
void setOperator(const QString &)
sets the operator AND/OR
QString conditionOperator()
returns the AND/OR condition
A database of saved style entities, including symbols, color ramps, text formats and others.
QMultiMap< QString, QString > QgsSmartConditionMap
A multimap to hold the smart group conditions as constraint and parameter pairs.