Skip to content

Commit

Permalink
Made 'saveAsShapefile' a slot in QgsVectorLayer such that it works ag…
Browse files Browse the repository at this point in the history
…ain. Enter the 'save as shapefile' option into the legend layer right click menu

git-svn-id: http://svn.osgeo.org/qgis/trunk@5717 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Aug 21, 2006
1 parent 18d2744 commit a1069f9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/gui/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3445,7 +3445,6 @@ void QgsVectorLayer::saveAsShapefile()
{
// call the dataproviders saveAsShapefile method
dataProvider->saveAsShapefile();
// QMessageBox::information(0,"Save As Shapefile", "Someday...");
}

void QgsVectorLayer::setCoordinateSystem()
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ public slots:
*/
virtual void updateExtents();

//! Save as shapefile
virtual void saveAsShapefile();


public:

Expand Down Expand Up @@ -378,9 +381,6 @@ public slots:
/**Returns true if the provider has been modified since the last commit*/
virtual bool isModified() const {return mModified;}

//! Save as shapefile
virtual void saveAsShapefile();

/**Snaps a point to the closest vertex if there is one within the snapping tolerance
@param point The point which is set to the position of a vertex if there is one within the snapping tolerance.
If there is no point within this tolerance, point is left unchanged.
Expand Down
23 changes: 23 additions & 0 deletions src/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "qgsmaplayerregistry.h"
#include "qgsproject.h"
#include "qgsrasterlayerproperties.h"
#include "qgsvectordataprovider.h"

#include <cfloat>
#include <QCoreApplication>
Expand Down Expand Up @@ -435,6 +436,13 @@ void QgsLegend::handleRightClickEvent(QTreeWidgetItem* item, const QPoint& posit
{
toggleEditingAction->setEnabled(false);
}
else
{
if(theVectorLayer->getDataProvider()->capabilities() | QgsVectorDataProvider::SaveAsShapefile)
{
theMenu.addAction(tr("&Save as shapefile..."), this, SLOT(legendLayerSaveAsShapefile()));
}
}
if(theVectorLayer)
{
toggleEditingAction->setChecked(theVectorLayer->isEditable());
Expand Down Expand Up @@ -717,6 +725,21 @@ void QgsLegend::legendLayerToggleEditing()
}
}

void QgsLegend::legendLayerSaveAsShapefile()
{
QgsLegendLayer* ll = dynamic_cast<QgsLegendLayer*>(currentItem());
if(!ll)
{
return;
}
QgsVectorLayer* theVectorLayer = dynamic_cast<QgsVectorLayer*>(ll->firstMapLayer());
if(!theVectorLayer)
{
return;
}
theVectorLayer->saveAsShapefile();
}

void QgsLegend::expandAll()
{
QTreeWidgetItem* theItem = firstItem();
Expand Down
2 changes: 2 additions & 0 deletions src/legend/qgslegend.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ this item may be moved back to the original position with resetToInitialPosition
void legendLayerShowProperties();
/**Toggles the editing mode of the first layer file of a legend layer*/
void legendLayerToggleEditing();
/**Saves the current layer to shapefile (if the provider supports it)*/
void legendLayerSaveAsShapefile();
/**Sets all listview items to open*/
void expandAll();
/**Sets all listview items to closed*/
Expand Down

0 comments on commit a1069f9

Please sign in to comment.