Skip to content

Commit

Permalink
Added warning when attempting to create an attribute action without
Browse files Browse the repository at this point in the history
    specifying both a name and and the action to perform. Fixes bug #1596


git-svn-id: http://svn.osgeo.org/qgis/trunk@10575 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gsherman committed Apr 16, 2009
1 parent 45e4ded commit 4a943d1
Showing 1 changed file with 35 additions and 21 deletions.
56 changes: 35 additions & 21 deletions src/app/qgsattributeactiondialog.cpp
Expand Up @@ -26,6 +26,7 @@ back to QgsVectorLayer.

#include <QFileDialog>
#include <QHeaderView>
#include <QMessageBox>


QgsAttributeActionDialog::QgsAttributeActionDialog( QgsAttributeAction* actions,
Expand Down Expand Up @@ -178,32 +179,45 @@ void QgsAttributeActionDialog::insert()

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).

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 )
if ( actionName->text().isEmpty() || actionAction->text().isEmpty() )
{
// Expand the table to have a row with index pos
insertRow( pos, name, actionAction->text(), captureCB->isChecked() );
QMessageBox::warning( this, tr( "Missing Information" ),
tr( "To create an attribute action, you must provide both a name and the action to perform." ) );

}
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 );
}
}
}

Expand Down

0 comments on commit 4a943d1

Please sign in to comment.