def addInfoActions(layer):
    commitId = getCommitId(layer)
    tracking = getTrackingInfo(layer)
    repo = Repository(tracking.repoUrl)
    _infoActions[layer.id()] = []
    try:
        commit = Commit.fromref(repo, commitId)
        messageAction = QAction(
            "Message: '%s'" % commit.message.splitlines()[0],
            config.iface.legendInterface())
        f = messageAction.font()
        f.setBold(True)
        messageAction.setFont(f)
        config.iface.legendInterface().addLegendLayerAction(
            messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(
            messageAction, layer)
        _infoActions[layer.id()].append(messageAction)
    except Exception, e:
        QgsMessageLog.logMessage(
            "Cannot connect to server when creating GeoGig layer context:\n %s"
            % str(e),
            level=QgsMessageLog.WARNING)
        messageAction = QAction("Error: Cannot connect with repository",
                                config.iface.legendInterface())
        f = messageAction.font()
        f.setBold(True)
        messageAction.setFont(f)
        config.iface.legendInterface().addLegendLayerAction(
            messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(
            messageAction, layer)
        _infoActions[layer.id()].append(messageAction)
        return False
예제 #2
0
def addInfoActions(layer):
    commitId = getCommitId(layer)
    tracking = getTrackingInfo(layer)
    repo = Repository(tracking.repoUrl)
    layer.infoActions = []
    try:
        commit = Commit.fromref(repo, commitId)
        messageAction = QAction(
            "Message: '%s'" % commit.message.splitlines()[0],
            config.iface.legendInterface())
        f = messageAction.font()
        f.setBold(True)
        messageAction.setFont(f)
        config.iface.legendInterface().addLegendLayerAction(
            messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(
            messageAction, layer)
        layer.infoActions.append(messageAction)
    except:
        messageAction = QAction("Error: Cannot connect with repository",
                                config.iface.legendInterface())
        f = messageAction.font()
        f.setBold(True)
        messageAction.setFont(f)
        config.iface.legendInterface().addLegendLayerAction(
            messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(
            messageAction, layer)
        layer.infoActions.append(messageAction)
        return False
    shaAction = QAction("Version ID: %s" % commitId,
                        config.iface.legendInterface())
    f = shaAction.font()
    f.setBold(True)
    shaAction.setFont(f)
    config.iface.legendInterface().addLegendLayerAction(
        shaAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
    config.iface.legendInterface().addLegendLayerActionForLayer(
        shaAction, layer)
    layer.infoActions.append(shaAction)
    return True
def addInfoActions(layer):
    commitId = getCommitId(layer)
    tracking = getTrackingInfo(layer)
    repo = Repository(tracking.repoUrl)
    _infoActions[layer.id()] = []
    try:
        commit = Commit.fromref(repo, commitId)
        messageAction = QAction("Message: '%s'" % commit.message.splitlines()[0], config.iface.legendInterface())
        f = messageAction.font();
        f.setBold(True);
        messageAction.setFont(f);
        config.iface.legendInterface().addLegendLayerAction(messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(messageAction, layer)
        _infoActions[layer.id()].append(messageAction)
    except Exception, e:
        QgsMessageLog.logMessage("Cannot connect to server when creating GeoGig layer context:\n %s" % str(e), level=QgsMessageLog.WARNING)
        messageAction = QAction("Error: Cannot connect with repository", config.iface.legendInterface())
        f = messageAction.font();
        f.setBold(True);
        messageAction.setFont(f);
        config.iface.legendInterface().addLegendLayerAction(messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(messageAction, layer)
        _infoActions[layer.id()].append(messageAction)
        return False
            % str(e),
            level=QgsMessageLog.WARNING)
        messageAction = QAction("Error: Cannot connect with repository",
                                config.iface.legendInterface())
        f = messageAction.font()
        f.setBold(True)
        messageAction.setFont(f)
        config.iface.legendInterface().addLegendLayerAction(
            messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(
            messageAction, layer)
        _infoActions[layer.id()].append(messageAction)
        return False
    shaAction = QAction("Commit ID: %s" % commitId,
                        config.iface.legendInterface())
    f = shaAction.font()
    f.setBold(True)
    shaAction.setFont(f)
    config.iface.legendInterface().addLegendLayerAction(
        shaAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
    config.iface.legendInterface().addLegendLayerActionForLayer(
        shaAction, layer)
    _infoActions[layer.id()].append(shaAction)
    return True


def updateInfoActions(layer):
    setAsRepoLayer(layer)


def setAsNonRepoLayer(layer):
        messageAction.setFont(f);
        config.iface.legendInterface().addLegendLayerAction(messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(messageAction, layer)
        _infoActions[layer.id()].append(messageAction)
    except Exception, e:
        QgsMessageLog.logMessage("Cannot connect to server when creating GeoGig layer context:\n %s" % str(e), level=QgsMessageLog.WARNING)
        messageAction = QAction("Error: Cannot connect with repository", config.iface.legendInterface())
        f = messageAction.font();
        f.setBold(True);
        messageAction.setFont(f);
        config.iface.legendInterface().addLegendLayerAction(messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(messageAction, layer)
        _infoActions[layer.id()].append(messageAction)
        return False
    shaAction = QAction("Commit ID: %s" % commitId, config.iface.legendInterface())
    f = shaAction.font();
    f.setBold(True);
    shaAction.setFont(f);
    config.iface.legendInterface().addLegendLayerAction(shaAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
    config.iface.legendInterface().addLegendLayerActionForLayer(shaAction, layer)
    _infoActions[layer.id()].append(shaAction)
    return True

def updateInfoActions(layer):
    setAsRepoLayer(layer)

def setAsNonRepoLayer(layer):
    removeLayerActions(layer)
    action = QAction("Import to GeoGig...", config.iface.legendInterface())
    action.triggered.connect(partial(addLayer, layer))
    if layer.type() == QgsMapLayer.RasterLayer or layer.storageType() != 'GPKG':