Ok here is the Python that I used to do it:
layer = qgis.utils.iface.mapCanvas().currentLayer()
for feature in layer.selectedFeatures():
geom = feature.geometry()
nodes = geom.asPolyline()
newgeom = QgsGeometry.fromPolyline(nodes)
Before running the above code:
- Select the layer you want to edit;
- Toggle Editing on;
- Select the features in this layer you want to reverse.
Run the above python code by:
- Going to Plugins > Python Console;
- Copying and pasting the code into the window;
- Hit Enter 2x to run.
It should output "True" for each feature whose direction was swapped. If it outputs "False" then it didn't swap that feature's direction. This will happen if the layer doesn't have Editing toggled on.
I have wrapped it up in a plugin called
Swap Line Direction and it's available in the QGIS plugin installer.
This plugin is no longer available (as of 11/16/2015) in the plugin installer but you can build your own pretty easily with the "Plugin Builder" plugin.
I'll have a look at how easy it is to intergrate with fTools.