Skip to content

Commit 262df8a

Browse files
committed
Merge branch 'master' of github.com:qgis/Quantum-GIS
2 parents c8ca7d7 + 516fc7e commit 262df8a

5 files changed

+39
-2
lines changed

src/app/qgsattributeactiondialog.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ QgsAttributeActionDialog::QgsAttributeActionDialog( QgsAttributeAction* actions,
5050
connect( moveUpButton, SIGNAL( clicked() ), this, SLOT( moveUp() ) );
5151
connect( moveDownButton, SIGNAL( clicked() ), this, SLOT( moveDown() ) );
5252
connect( removeButton, SIGNAL( clicked() ), this, SLOT( remove() ) );
53+
connect( addDefaultActionsButton, SIGNAL( clicked() ), this, SLOT( addDefaultActions() ) );
54+
5355
connect( browseButton, SIGNAL( clicked() ), this, SLOT( browse() ) );
5456
connect( insertButton, SIGNAL( clicked() ), this, SLOT( insert() ) );
5557
connect( updateButton, SIGNAL( clicked() ), this, SLOT( update() ) );
@@ -319,6 +321,18 @@ void QgsAttributeActionDialog::apply()
319321
}
320322
}
321323

324+
void QgsAttributeActionDialog::addDefaultActions()
325+
{
326+
int pos = 0;
327+
insertRow( pos++, QgsAction::Generic, tr( "Echo attribute's value" ), "echo \"[% \"MY_FIELD\" %]\"", true );
328+
insertRow( pos++, QgsAction::Generic, tr( "Run an application" ), "ogr2ogr -f \"ESRI Shapefile\" \"[% \"OUTPUT_PATH\" %]\" \"[% \"INPUT_FILE\" %]\"", true );
329+
insertRow( pos++, QgsAction::GenericPython, tr( "Get feature id" ), "QtGui.QMessageBox.information(None, \"Feature id\", \"feature id is [% $id %]\")", false );
330+
insertRow( pos++, QgsAction::GenericPython, tr( "Selected field's value (Identify features tool)" ), "QtGui.QMessageBox.information(None, \"Current field's value\", \"[% $currentfield %]\")", false );
331+
insertRow( pos++, QgsAction::GenericPython, tr( "Clicked coordinates (Run feature actions tool)" ), "QtGui.QMessageBox.information(None, \"Clicked coords\", \"layer: [% $layerid %]\\ncoords: ([% $clickx %],[% $clickx %])\")", false );
332+
insertRow( pos++, QgsAction::OpenUrl, tr( "Open file" ), "[% \"PATH\" %]", false );
333+
insertRow( pos++, QgsAction::OpenUrl, tr( "Search on web based on attribute's value" ), "http://www.google.it/?q=[% \"ATTRIBUTE\" %]", false );
334+
}
335+
322336
void QgsAttributeActionDialog::itemSelectionChanged()
323337
{
324338
QList<QTableWidgetItem *> selection = attributeActionTable->selectedItems();

src/app/qgsattributeactiondialog.h

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class QgsAttributeActionDialog: public QWidget, private Ui::QgsAttributeActionDi
5353
void insertExpression();
5454
void apply();
5555
void update();
56+
void addDefaultActions();
5657
void itemSelectionChanged();
5758

5859
private slots:

src/core/qgsattributeaction.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,15 @@ void QgsAttributeAction::doAction( int index, QgsFeature &feat,
106106

107107
void QgsAttributeAction::runAction( const QgsAction &action, void ( *executePython )( const QString & ) )
108108
{
109-
if ( action.type() == QgsAction::GenericPython )
109+
if ( action.type() == QgsAction::OpenUrl )
110+
{
111+
QFileInfo finfo( action.action() );
112+
if ( finfo.exists() && finfo.isFile() )
113+
QDesktopServices::openUrl( QUrl::fromLocalFile( action.action() ) );
114+
else
115+
QDesktopServices::openUrl( QUrl( action.action(), QUrl::TolerantMode ) );
116+
}
117+
else if ( action.type() == QgsAction::GenericPython )
110118
{
111119
if ( executePython )
112120
{

src/core/qgsattributeaction.h

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class CORE_EXPORT QgsAction
4747
Mac,
4848
Windows,
4949
Unix,
50+
OpenUrl,
5051
};
5152

5253
QgsAction( ActionType type, QString name, QString action, bool capture ) :
@@ -69,6 +70,7 @@ class CORE_EXPORT QgsAction
6970
{
7071
return mType == Generic ||
7172
mType == GenericPython ||
73+
mType == OpenUrl ||
7274
#if defined(Q_OS_WIN)
7375
mType == Windows
7476
#elif defined(Q_OS_MAC)

src/ui/qgsattributeactiondialogbase.ui

+13-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<string>Action list</string>
2727
</property>
2828
<layout class="QGridLayout" name="gridLayout_3">
29-
<item row="0" column="0" colspan="4">
29+
<item row="0" column="0" colspan="5">
3030
<widget class="QTableWidget" name="attributeActionTable">
3131
<property name="sizePolicy">
3232
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -98,6 +98,13 @@
9898
</property>
9999
</widget>
100100
</item>
101+
<item row="1" column="4">
102+
<widget class="QPushButton" name="addDefaultActionsButton">
103+
<property name="text">
104+
<string>Add default actions</string>
105+
</property>
106+
</widget>
107+
</item>
101108
</layout>
102109
</widget>
103110
</item>
@@ -152,6 +159,11 @@
152159
<string>Unix</string>
153160
</property>
154161
</item>
162+
<item>
163+
<property name="text">
164+
<string>Open</string>
165+
</property>
166+
</item>
155167
</widget>
156168
</item>
157169
<item>

0 commit comments

Comments
 (0)