@@ -26,6 +26,7 @@ back to QgsVectorLayer.
26
26
27
27
#include < QFileDialog>
28
28
#include < QHeaderView>
29
+ #include < QMessageBox>
29
30
30
31
31
32
QgsAttributeActionDialog::QgsAttributeActionDialog ( QgsAttributeAction* actions,
@@ -178,32 +179,45 @@ void QgsAttributeActionDialog::insert()
178
179
179
180
void QgsAttributeActionDialog::insert ( int pos )
180
181
{
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
183
184
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 () )
196
186
{
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
+
199
190
}
200
191
else
201
192
{
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
+ }
207
221
}
208
222
}
209
223
0 commit comments