Added hook for a provider to indicate it supports saving its data to a shapefile. If supported, an item is added to the popup context menu. The save function is not implmented yet.

git-svn-id: http://svn.osgeo.org/qgis/trunk@2319 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2004-11-23 06:14:05 +00:00
parent 13f37c35c1
commit a15bae505d
5 changed files with 23 additions and 0 deletions

View File

@ -178,6 +178,7 @@ class QgsPostgresProvider:public QgsVectorDataProvider
bool supportsFeatureDeletion(){return true;} bool supportsFeatureDeletion(){return true;}
bool supportsSaveAsShapefile(){return true;}
/** Accessor for sql where clause used to limit dataset */ /** Accessor for sql where clause used to limit dataset */
QString subsetString() {return sqlWhereClause;}; QString subsetString() {return sqlWhereClause;};
//! Get the postgres connection //! Get the postgres connection

View File

@ -51,3 +51,9 @@ bool QgsVectorDataProvider::supportsFeatureDeletion()
//needs to be overwritten by providers which support this //needs to be overwritten by providers which support this
return false; return false;
} }
bool QgsVectorDataProvider::supportsSaveAsShapefile()
{
// default implementation is no support
return true;
}

View File

@ -117,6 +117,9 @@ class QgsVectorDataProvider: public QgsDataProvider
/**Returns true if a provider supports deleting features*/ /**Returns true if a provider supports deleting features*/
virtual bool supportsFeatureDeletion(); virtual bool supportsFeatureDeletion();
/** Returns true is the provider supports saving to shapefile*/
virtual bool supportsSaveAsShapefile();
}; };
#endif #endif

View File

@ -786,6 +786,13 @@ void QgsVectorLayer::select(int number)
popMenu->insertItem(tr("Start editing"),this,SLOT(startEditing())); popMenu->insertItem(tr("Start editing"),this,SLOT(startEditing()));
popMenu->insertItem(tr("Stop editing"),this,SLOT(stopEditing())); popMenu->insertItem(tr("Stop editing"),this,SLOT(stopEditing()));
// XXX Can we ask the provider if it wants to add things to the context menu?
if(dataProvider->supportsSaveAsShapefile())
{
// add the save as shapefile menu item
popMenu->insertItem(tr("Save as shapefile..."), this, SLOT(saveAsShapefile()));
}
} // QgsVectorLayer::initContextMenu_(QgisApp * app) } // QgsVectorLayer::initContextMenu_(QgisApp * app)
@ -2067,3 +2074,7 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsCoordinateTran
break; break;
} }
} }
void QgsVectorLayer::saveAsShapefile(){
QMessageBox::information(0,"Save As Shapefile", "Someday...");
}

View File

@ -232,6 +232,8 @@ class QgsVectorLayer : public QgsMapLayer
/**Returns true if the provider has been modified since the last commit*/ /**Returns true if the provider has been modified since the last commit*/
virtual bool isModified() const {return mModified;} virtual bool isModified() const {return mModified;}
//! Save as shapefile
void saveAsShapefile();
protected: protected:
/**Pointer to the table display object if there is one, else a pointer to 0*/ /**Pointer to the table display object if there is one, else a pointer to 0*/
QgsAttributeTableDisplay * tabledisplay; QgsAttributeTableDisplay * tabledisplay;