Skip to content
Permalink
Browse files
Merge branch 'master' of github.com:qgis/Quantum-GIS
  • Loading branch information
timlinux committed Mar 28, 2012
2 parents c8ca7d7 + 516fc7e commit 262df8af172087bf55b5c8ee23a18fdeb91e36ef
@@ -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,18 @@ 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 );
insertRow( pos++, QgsAction::OpenUrl, tr( "Open file" ), "[% \"PATH\" %]", false );
insertRow( pos++, QgsAction::OpenUrl, tr( "Search on web based on attribute's value" ), "http://www.google.it/?q=[% \"ATTRIBUTE\" %]", 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:
@@ -106,7 +106,15 @@ void QgsAttributeAction::doAction( int index, QgsFeature &feat,

void QgsAttributeAction::runAction( const QgsAction &action, void ( *executePython )( const QString & ) )
{
if ( action.type() == QgsAction::GenericPython )
if ( action.type() == QgsAction::OpenUrl )
{
QFileInfo finfo( action.action() );
if ( finfo.exists() && finfo.isFile() )
QDesktopServices::openUrl( QUrl::fromLocalFile( action.action() ) );
else
QDesktopServices::openUrl( QUrl( action.action(), QUrl::TolerantMode ) );
}
else if ( action.type() == QgsAction::GenericPython )
{
if ( executePython )
{
@@ -47,6 +47,7 @@ class CORE_EXPORT QgsAction
Mac,
Windows,
Unix,
OpenUrl,
};

QgsAction( ActionType type, QString name, QString action, bool capture ) :
@@ -69,6 +70,7 @@ class CORE_EXPORT QgsAction
{
return mType == Generic ||
mType == GenericPython ||
mType == OpenUrl ||
#if defined(Q_OS_WIN)
mType == Windows
#elif defined(Q_OS_MAC)
@@ -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>
@@ -152,6 +159,11 @@
<string>Unix</string>
</property>
</item>
<item>
<property name="text">
<string>Open</string>
</property>
</item>
</widget>
</item>
<item>

0 comments on commit 262df8a

Please sign in to comment.