[QGIS Commit] r10575 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Apr 15 23:48:47 EDT 2009


Author: gsherman
Date: 2009-04-15 23:48:46 -0400 (Wed, 15 Apr 2009)
New Revision: 10575

Modified:
   trunk/qgis/src/app/qgsattributeactiondialog.cpp
Log:
    Added warning when attempting to create an attribute action without
    specifying both a name and and the action to perform. Fixes bug #1596


Modified: trunk/qgis/src/app/qgsattributeactiondialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsattributeactiondialog.cpp	2009-04-15 23:53:30 UTC (rev 10574)
+++ trunk/qgis/src/app/qgsattributeactiondialog.cpp	2009-04-16 03:48:46 UTC (rev 10575)
@@ -26,6 +26,7 @@
 
 #include <QFileDialog>
 #include <QHeaderView>
+#include <QMessageBox>
 
 
 QgsAttributeActionDialog::QgsAttributeActionDialog( QgsAttributeAction* actions,
@@ -178,32 +179,45 @@
 
 void QgsAttributeActionDialog::insert( int pos )
 {
-  // Get the action details and insert into the table at the given
-  // position. Name needs to be unique, so make it so if required.
+  // Check to see if the action name and the action have been specified
+  // before proceeding
 
-  // If the new action name is the same as the action name in the
-  // given pos, don't make the new name unique (because we're
-  // replacing it).
+  if ( actionName->text().isEmpty() || actionAction->text().isEmpty() )
+  {
+    QMessageBox::warning( this, tr( "Missing Information" ), 
+        tr( "To create an attribute action, you must provide both a name and the action to perform." ) );
 
-  int numRows = attributeActionTable->rowCount();
-  QString name;
-  if ( pos < numRows && actionName->text() == attributeActionTable->item( pos, 0 )->text() )
-    name = actionName->text();
-  else
-    name = uniqueName( actionName->text() );
-
-  if ( pos >= numRows )
-  {
-    // Expand the table to have a row with index pos
-    insertRow( pos, name, actionAction->text(), captureCB->isChecked() );
   }
   else
   {
-    // Update existing row
-    attributeActionTable->item( pos, 0 )->setText( name );
-    attributeActionTable->item( pos, 1 )->setText( actionAction->text() );
-    attributeActionTable->item( pos, 2 )->setCheckState(
-      captureCB->isChecked() ? Qt::Checked : Qt::Unchecked );
+
+    // Get the action details and insert into the table at the given
+    // position. Name needs to be unique, so make it so if required.
+
+    // If the new action name is the same as the action name in the
+    // given pos, don't make the new name unique (because we're
+    // replacing it).
+
+    int numRows = attributeActionTable->rowCount();
+    QString name;
+    if ( pos < numRows && actionName->text() == attributeActionTable->item( pos, 0 )->text() )
+      name = actionName->text();
+    else
+      name = uniqueName( actionName->text() );
+
+    if ( pos >= numRows )
+    {
+      // Expand the table to have a row with index pos
+      insertRow( pos, name, actionAction->text(), captureCB->isChecked() );
+    }
+    else
+    {
+      // Update existing row
+      attributeActionTable->item( pos, 0 )->setText( name );
+      attributeActionTable->item( pos, 1 )->setText( actionAction->text() );
+      attributeActionTable->item( pos, 2 )->setCheckState(
+          captureCB->isChecked() ? Qt::Checked : Qt::Unchecked );
+    }
   }
 }
 



More information about the QGIS-commit mailing list