Skip to content
Permalink
Browse files
feature actions: new button to add some default actions
  • Loading branch information
brushtyler committed Mar 28, 2012
1 parent 04e8268 commit 1786b96ba80bd2a707677ee4612cd1c948a0f9b6
Showing with 21 additions and 1 deletion.
  1. +12 −0 src/app/qgsattributeactiondialog.cpp
  2. +1 −0 src/app/qgsattributeactiondialog.h
  3. +8 −1 src/ui/qgsattributeactiondialogbase.ui
@@ -50,6 +50,8 @@ QgsAttributeActionDialog::QgsAttributeActionDialog( QgsAttributeAction* actions,
connect( moveUpButton, SIGNAL( clicked() ), this, SLOT( moveUp() ) );
connect( moveDownButton, SIGNAL( clicked() ), this, SLOT( moveDown() ) );
connect( removeButton, SIGNAL( clicked() ), this, SLOT( remove() ) );
connect( addDefaultActionsButton, SIGNAL( clicked() ), this, SLOT( addDefaultActions() ) );

connect( browseButton, SIGNAL( clicked() ), this, SLOT( browse() ) );
connect( insertButton, SIGNAL( clicked() ), this, SLOT( insert() ) );
connect( updateButton, SIGNAL( clicked() ), this, SLOT( update() ) );
@@ -319,6 +321,16 @@ void QgsAttributeActionDialog::apply()
}
}

void QgsAttributeActionDialog::addDefaultActions()
{
int pos = 0;
insertRow( pos++, QgsAction::Generic, tr( "Echo attribute's value" ), "echo \"[% \"MY_FIELD\" %]\"", true );
insertRow( pos++, QgsAction::Generic, tr( "Run an application" ), "ogr2ogr -f \"ESRI Shapefile\" \"[% \"OUTPUT_PATH\" %]\" \"[% \"INPUT_FILE\" %]\"", true );
insertRow( pos++, QgsAction::GenericPython, tr( "Get feature id" ), "QtGui.QMessageBox.information(None, \"Feature id\", \"feature id is [% $id %]\")", false );
insertRow( pos++, QgsAction::GenericPython, tr( "Selected field's value (Identify features tool)" ), "QtGui.QMessageBox.information(None, \"Current field's value\", \"[% $currentfield %]\")", false );
insertRow( pos++, QgsAction::GenericPython, tr( "Clicked coordinates (Run feature actions tool)" ), "QtGui.QMessageBox.information(None, \"Clicked coords\", \"layer: [% $layerid %]\\ncoords: ([% $clickx %],[% $clickx %])\")", false );
}

void QgsAttributeActionDialog::itemSelectionChanged()
{
QList<QTableWidgetItem *> selection = attributeActionTable->selectedItems();
@@ -53,6 +53,7 @@ class QgsAttributeActionDialog: public QWidget, private Ui::QgsAttributeActionDi
void insertExpression();
void apply();
void update();
void addDefaultActions();
void itemSelectionChanged();

private slots:
@@ -26,7 +26,7 @@
<string>Action list</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0" colspan="4">
<item row="0" column="0" colspan="5">
<widget class="QTableWidget" name="attributeActionTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -98,6 +98,13 @@
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="addDefaultActionsButton">
<property name="text">
<string>Add default actions</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

0 comments on commit 1786b96

Please sign in to comment.