Skip to content
Permalink
Browse files
Made 'saveAsShapefile' a slot in QgsVectorLayer such that it works ag…
…ain. Enter the 'save as shapefile' option into the legend layer right click menu

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5717 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Aug 21, 2006
1 parent c2db9e6 commit d5d423a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
@@ -3445,7 +3445,6 @@ void QgsVectorLayer::saveAsShapefile()
{
// call the dataproviders saveAsShapefile method
dataProvider->saveAsShapefile();
// QMessageBox::information(0,"Save As Shapefile", "Someday...");
}

void QgsVectorLayer::setCoordinateSystem()
@@ -209,6 +209,9 @@ public slots:
*/
virtual void updateExtents();

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


public:

@@ -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.
@@ -32,6 +32,7 @@
#include "qgsmaplayerregistry.h"
#include "qgsproject.h"
#include "qgsrasterlayerproperties.h"
#include "qgsvectordataprovider.h"

#include <cfloat>
#include <QCoreApplication>
@@ -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());
@@ -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();
@@ -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*/

0 comments on commit d5d423a

Please sign in to comment.