Place 'allow editing' into the legend layer right click menu. Newly added vector layers are not editable per default any more

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5335 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2006-04-21 20:53:56 +00:00
parent d3a17de0f3
commit 97d368bc8d
4 changed files with 44 additions and 10 deletions

View File

@ -137,11 +137,6 @@ QgsVectorLayer::QgsVectorLayer(QString vectorLayerPath,
// have no effect on existing layers
QSettings settings;
updateThreshold = settings.readNumEntry("Map/updateThreshold", 1000);
//editing is now enabled by default
if(dataProvider->capabilities()&QgsVectorDataProvider::AddFeatures)
{
startEditing();
}
}
} // QgsVectorLayer ctor

View File

@ -183,6 +183,9 @@ public slots:
void triggerRepaint();
/**Shows the properties dialog*/
virtual void showLayerProperties();
void startEditing();
void stopEditing();
public:
@ -471,12 +474,8 @@ public:
protected slots:
void toggleEditing();
void startEditing();
void stopEditing();
void toggleEditing();
private: // Private attributes

View File

@ -407,6 +407,22 @@ void QgsLegend::handleRightClickEvent(QTreeWidgetItem* item, const QPoint& posit
{
theMenu.addAction(tr("&Make to toplevel item"), this, SLOT(makeToTopLevelItem()));
}
//add entry 'allow editing'
QAction* toggleEditingAction = theMenu.addAction(tr("&Allow editing"), this, SLOT(legendLayerToggleEditing()));
toggleEditingAction->setCheckable(true);
QgsLegendLayer* theLayer = dynamic_cast<QgsLegendLayer*>(li);
if(theLayer)
{
QgsVectorLayer* theVectorLayer = dynamic_cast<QgsVectorLayer*>(theLayer->firstMapLayer());
if(!theVectorLayer || theLayer->mapLayers().size() !=1)
{
toggleEditingAction->setEnabled(false);
}
if(theVectorLayer)
{
toggleEditingAction->setChecked(theVectorLayer->isEditable());
}
}
}
else if(li->type() == QgsLegendItem::LEGEND_GROUP)
{
@ -652,6 +668,28 @@ void QgsLegend::legendLayerShowProperties()
ml->showLayerProperties();
}
void QgsLegend::legendLayerToggleEditing()
{
QgsLegendLayer* ll = dynamic_cast<QgsLegendLayer*>(currentItem());
if(!ll)
{
return;
}
QgsVectorLayer* theVectorLayer = dynamic_cast<QgsVectorLayer*>(ll->firstMapLayer());
if(!theVectorLayer)
{
return;
}
if(theVectorLayer->isEditable())
{
theVectorLayer->stopEditing();
}
else
{
theVectorLayer->startEditing();
}
}
void QgsLegend::expandAll()
{
QTreeWidgetItem* theItem = firstItem();

View File

@ -256,6 +256,8 @@ this item may be moved back to the original position with resetToInitialPosition
void legendLayerRemoveFromOverview();
/**Shows the property dialog of the first legend layer file in a legend layer*/
void legendLayerShowProperties();
/**Toggles the editing mode of the first layer file of a legend layer*/
void legendLayerToggleEditing();
/**Sets all listview items to open*/
void expandAll();
/**Sets all listview items to closed*/