Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
feature actions: new "Open" action type to open urls in the default w…
…eb browser and files with a suitable application
- Loading branch information
|
@@ -329,6 +329,8 @@ void QgsAttributeActionDialog::addDefaultActions() |
|
|
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() |
|
|
|
@@ -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) |
|
|
|
@@ -159,6 +159,11 @@ |
|
|
<string>Unix</string> |
|
|
</property> |
|
|
</item> |
|
|
<item> |
|
|
<property name="text"> |
|
|
<string>Open</string> |
|
|
</property> |
|
|
</item> |
|
|
</widget> |
|
|
</item> |
|
|
<item> |
|
|