@@ -26,6 +26,7 @@ back to QgsVectorLayer.
2626
2727#include < QFileDialog>
2828#include < QHeaderView>
29+ #include < QMessageBox>
2930
3031
3132QgsAttributeActionDialog::QgsAttributeActionDialog ( QgsAttributeAction* actions,
@@ -178,32 +179,45 @@ void QgsAttributeActionDialog::insert()
178179
179180void QgsAttributeActionDialog::insert ( int pos )
180181{
181- // Get the action details and insert into the table at the given
182- // position. Name needs to be unique, so make it so if required.
182+ // Check to see if the action name and the action have been specified
183+ // before proceeding
183184
184- // If the new action name is the same as the action name in the
185- // given pos, don't make the new name unique (because we're
186- // replacing it).
187-
188- int numRows = attributeActionTable->rowCount ();
189- QString name;
190- if ( pos < numRows && actionName->text () == attributeActionTable->item ( pos, 0 )->text () )
191- name = actionName->text ();
192- else
193- name = uniqueName ( actionName->text () );
194-
195- if ( pos >= numRows )
185+ if ( actionName->text ().isEmpty () || actionAction->text ().isEmpty () )
196186 {
197- // Expand the table to have a row with index pos
198- insertRow ( pos, name, actionAction->text (), captureCB->isChecked () );
187+ QMessageBox::warning ( this , tr ( " Missing Information" ),
188+ tr ( " To create an attribute action, you must provide both a name and the action to perform." ) );
189+
199190 }
200191 else
201192 {
202- // Update existing row
203- attributeActionTable->item ( pos, 0 )->setText ( name );
204- attributeActionTable->item ( pos, 1 )->setText ( actionAction->text () );
205- attributeActionTable->item ( pos, 2 )->setCheckState (
206- captureCB->isChecked () ? Qt::Checked : Qt::Unchecked );
193+
194+ // Get the action details and insert into the table at the given
195+ // position. Name needs to be unique, so make it so if required.
196+
197+ // If the new action name is the same as the action name in the
198+ // given pos, don't make the new name unique (because we're
199+ // replacing it).
200+
201+ int numRows = attributeActionTable->rowCount ();
202+ QString name;
203+ if ( pos < numRows && actionName->text () == attributeActionTable->item ( pos, 0 )->text () )
204+ name = actionName->text ();
205+ else
206+ name = uniqueName ( actionName->text () );
207+
208+ if ( pos >= numRows )
209+ {
210+ // Expand the table to have a row with index pos
211+ insertRow ( pos, name, actionAction->text (), captureCB->isChecked () );
212+ }
213+ else
214+ {
215+ // Update existing row
216+ attributeActionTable->item ( pos, 0 )->setText ( name );
217+ attributeActionTable->item ( pos, 1 )->setText ( actionAction->text () );
218+ attributeActionTable->item ( pos, 2 )->setCheckState (
219+ captureCB->isChecked () ? Qt::Checked : Qt::Unchecked );
220+ }
207221 }
208222}
209223
0 commit comments