Tuesday 19 March 2019

qgis plugins - Get signal on edited feature?


Regarding my pyqgis plugin 2.2 , I've implemented signal on a vector layer event successfully. For instance, whenever i create a new feature, i can read a new basic message appeared via QGIS logging system : " feature added".


But for some events, besides this basic message, i would like read the name of the layer and/or , the id of the feature/ the attribut name / the geometry type (line,surf,punct).


How to bring more info details for the events?


I paste below my piece of code :


def logLayerModified(self, onlyGeometry = None ): 
QgsMessageLog.logMessage( "layer modified" )
QApplication.beep()

def logAttributeAdded(self,QgsFeatureId):

QgsMessageLog.logMessage( "attribut added" )
QApplication.beep()

def logAttributeDeleted(self,QgsFeatureId):
QgsMessageLog.logMessage( "attribut deleted" )
QApplication.beep()

def logFeatureAdded(self,QgsFeatureId):
QgsMessageLog.logMessage("feature added, id = " + str(QgsFeatureId))
QApplication.beep()


def logFeatureDeleted(self,QgsFeatureId):
QgsMessageLog.logMessage("feature deleted, id = " + str(QgsFeatureId))
QApplication.beep()

def logGeometryChanged(self,fid):
QgsMessageLog.logMessage("Geometry changed, id = " + str(fid))
QApplication.beep()

def logAttributeValueChanged(self, QgsFeatureId fid, int idx, const QVariant &):

QgsMessageLog.logMessage("Attribut value changed", id = " + str(QgsFeatureId))
QApplication.beep()

def logBeforeLayerCommitChange(self):
QgsMessageLog.logMessage( "commit change" )
QApplication.beep()

layer.layerModified.connect(self.logLayerModified)
layer.attributeAdded.connect(self.logAttributeAdded)
layer.attributeDeleted.connect(self.logAttributeDeleted)

layer.featureAdded.connect(self.logFeatureAdded)
layer.featureDeleted.connect(self.logFeatureDeleted)
layer.featureDeleted.connect(self.logGeometryChanged)
layer.beforeCommitChanges.connect(self.logBeforeLayerCommitChange)
layer.AttributeValueChanged.connect(self.logAttributeValueChanged)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...