22 #include <QMessageBox> 33 mCondCombo->addItem(
tr(
"has the tag" ), QVariant(
"tag" ) );
34 mCondCombo->addItem(
tr(
"is a member of group" ), QVariant(
"group" ) );
35 mCondCombo->addItem(
tr(
"has a part of name matching" ), QVariant(
"name" ) );
36 mCondCombo->addItem(
tr(
"does NOT have the tag" ), QVariant(
"!tag" ) );
37 mCondCombo->addItem(
tr(
"is NOT a member of group" ), QVariant(
"!group" ) );
38 mCondCombo->addItem(
tr(
"has NO part of name matching" ), QVariant(
"!name" ) );
42 connect( mRemoveBtn, SIGNAL( clicked() ),
this, SLOT(
destruct() ) );
52 return mCondCombo->itemData( mCondCombo->currentIndex() ).toString();
57 return mCondLineEdit->text();
62 mCondCombo->setCurrentIndex( mCondCombo->findData( QVariant( constraint ) ) );
67 mCondLineEdit->setText( param );
72 mRemoveBtn->setVisible( !hide );
80 : QDialog( parent ), mStyle( style )
86 mAndOrCombo->addItem(
tr(
"ALL the constraints" ), QVariant(
"AND" ) );
87 mAndOrCombo->addItem(
tr(
"any ONE of the constraints" ), QVariant(
"OR" ) );
89 mLayout =
new QGridLayout( mConditionsBox );
92 connect( mAddConditionBtn, SIGNAL( clicked() ),
this, SLOT(
addCondition() ) );
101 return mNameLineEdit->text();
117 connect( cond, SIGNAL( removed(
int ) ),
this, SLOT(
removeCondition(
int ) ) );
155 return mAndOrCombo->itemData( mAndOrCombo->currentIndex() ).toString();
160 QStringList constraints;
161 constraints <<
"tag" <<
"group" <<
"name" <<
"!tag" <<
"!group" <<
"!name";
171 foreach (
const QString &constr, constraints )
173 QStringList params = map.values( constr );
174 foreach (
const QString ¶m, params )
182 connect( cond, SIGNAL( removed(
int ) ),
this, SLOT(
removeCondition(
int ) ) );
192 mAndOrCombo->setCurrentIndex( mAndOrCombo->findData( QVariant( op ) ) );
197 mNameLineEdit->setText( name );
202 if ( mNameLineEdit->text().isEmpty() )
204 QMessageBox::critical(
this,
tr(
"Invalid name" ),
tr(
"The smart group name field is empty. Kindly provide a name" ) );
void setConstraint(QString constraint)
sets the given constraint
QgsSmartConditionMap conditionMap()
returns the condition map
static QString iconPath(QString iconFile)
Returns path to the desired icon file.
QMultiMap< QString, QString > QgsSmartConditionMap
void on_buttonBox_accepted()
QgsSmartGroupEditorDialog(QgsStyleV2 *style, QWidget *parent=NULL)
void hideRemoveButton(bool hide)
sets the remove button hidden state to 'hide'
~QgsSmartGroupEditorDialog()
void setParameter(QString param)
sets the given param
void addCondition()
function to create a new ConditionBox and update UI
QString smartgroupName()
returns the value from mNameLineEdit
void setConditionMap(QgsSmartConditionMap)
sets up the GUI for the given conditionmap
void setOperator(QString)
sets the operator AND/OR
QString parameter()
returns the parameter
QMap< int, QgsSmartGroupCondition * > mConditionMap
void setSmartgroupName(QString)
sets the smart group Name
QString constraint()
returns the constraint key
void removeCondition(int)
slot to remove the condition with id int
QgsSmartGroupCondition(int id, QWidget *parent=NULL)
QString conditionOperator()
returns the AND/OR condition