コード例 #1
0
def addLayer(layer):
    if not layer.source().lower().endswith("shp"):
        QtGui.QMessageBox.warning(config.iface.mainWindow(), 'Cannot add layer',
                "Only shapefile layers are supported at the moment",
                QtGui.QMessageBox.Ok)
        return
    repos = localRepos()
    if repos:
        dlg = ImportDialog(config.iface.mainWindow(), layer = layer)
        dlg.exec_()
        if dlg.ok:
            config.iface.messageBar().pushMessage("Layer correctly added to repository",
                                              level = QgsMessageBar.INFO, duration = 4)
            config.iface.legendInterface().removeLegendLayerAction(addActions[layer])
            del addActions[layer]
            browseActions[layer] = QtGui.QAction(u"Browse layer history...", config.iface.legendInterface())
            config.iface.legendInterface().addLegendLayerAction(browseActions[layer], u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
            config.iface.legendInterface().addLegendLayerActionForLayer(browseActions[layer], layer)
            browseActions[layer].triggered.connect(lambda: layerHistory(layer))
            removeActions[layer] = QtGui.QAction(u"Remove layer from repository", config.iface.legendInterface())
            config.iface.legendInterface().addLegendLayerAction(removeActions[layer], u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
            config.iface.legendInterface().addLegendLayerActionForLayer(removeActions[layer], layer)
            removeActions[layer].triggered.connect(lambda: removeLayer(layer))
    else:
        QtGui.QMessageBox.warning(config.iface.mainWindow(), 'Cannot add layer',
                "No local repositories were found",
                QtGui.QMessageBox.Ok)
コード例 #2
0
 def addLayer(self):
     layers = [layer for layer in getVectorLayers()
                     if layer.source().lower().endswith("shp")
                     and not isTracked(layer)]
     if layers:
         dlg = ImportDialog(self, repo = self.currentRepo.repo())
         dlg.exec_()
         if dlg.ok:
             self.versionsTree.updateCurrentBranchItem()
             self.statusWidget.updateLabelText()
     else:
         QtGui.QMessageBox.warning(self, 'Cannot add layer',
             "No suitable layers can be found in your current QGIS project.\n"
             "Open the layers in QGIS before trying to add them.",
             QtGui.QMessageBox.Ok)
コード例 #3
0
 def addLayer(self):
     layers = [layer for layer in getVectorLayers()
                     if layer.source().lower().endswith("shp")
                     and not isTracked(layer)]
     if layers:
         dlg = ImportDialog(self, repo = self.currentRepo.repo())
         dlg.exec_()
         if dlg.ok:
             self.versionsTree.updateCurrentBranchItem()
             self.statusWidget.updateLabelText()
             self.updateCurrentRepoDescription()
             setAsTracked(dlg.layer)
     else:
         QtGui.QMessageBox.warning(self, 'Cannot add layer',
             "No suitable layers can be found in your current QGIS project.\n"
             "Open the layers in QGIS before trying to add them.",
             QtGui.QMessageBox.Ok)
コード例 #4
0
def addLayer(layer):
    if not layer.source().lower().split("|")[0].split(".")[-1] in [
            "geopkg", "gpkg"
    ]:
        QMessageBox.warning(
            config.iface.mainWindow(), 'Cannot import layer',
            "Only geopackage layers are supported at the moment",
            QMessageBox.Ok)
        return

    filename, layername = namesFromLayer(layer)
    l = QgsVectorLayer(filename, 'tmp', 'ogr')
    # only single-layer per file are supported
    spatialLayers = 0
    subLayers = l.dataProvider().subLayers()
    if len(subLayers) > 0:
        for lay in subLayers:
            tokens = lay.split(':')
            if len(tokens) > 4:
                tokens[1] += ":{}".format(tokens[2])
                del tokens[2]
            elif len(tokens) == 4:
                if tokens[3] != "None":
                    spatialLayers += 1
            else:
                continue

        if spatialLayers > 1:
            QMessageBox.warning(
                config.iface.mainWindow(), 'Cannot import layer',
                "Only geopackage layers with single sublayer are supported at the moment",
                QMessageBox.Ok)
            return

    repos = repository.repos
    if repos:
        dlg = ImportDialog(config.iface.mainWindow(), layer=layer)
        dlg.exec_()
        if dlg.ok:
            setAsRepoLayer(layer)
            repoWatcher.repoChanged.emit(dlg.repo)

    else:
        QMessageBox.warning(config.iface.mainWindow(), 'Cannot import layer',
                            "No repositories were found", QMessageBox.Ok)
コード例 #5
0
 def addLayer(self):
     layers = [
         layer for layer in getVectorLayers()
         if layer.source().lower().split("|")[0].split(".")[-1] in
         ["gpkg", "geopkg"] and not isRepoLayer(layer)
     ]
     if layers:
         dlg = ImportDialog(self, repo=self.currentRepo)
         dlg.exec_()
         if dlg.ok:
             #self.versionsTree.updateCurrentBranchItem()
             setAsRepoLayer(dlg.layer)
             repoWatcher.repoChanged.emit(self.currentRepo)
     else:
         QMessageBox.warning(
             self, 'Cannot add layer',
             "No suitable layers can be found in your current QGIS project.\n"
             "Only Geopackage layers that do not already belong to a repository can be added.",
             QMessageBox.Ok)
コード例 #6
0
def addLayer(layer):
    if not layer.source().lower().split("|")[0].split(".")[-1] in ["geopkg", "gpkg"]:
        QMessageBox.warning(config.iface.mainWindow(), 'Cannot import layer',
                "Only geopackage layers are supported at the moment",
                QMessageBox.Ok)
        return

    filename, layername = namesFromLayer(layer)
    l = QgsVectorLayer(filename, 'tmp', 'ogr')
    # only single-layer per file are supported
    spatialLayers = 0
    subLayers = l.dataProvider().subLayers()
    if len(subLayers) > 0:
        for lay in subLayers:
            tokens = lay.split(':')
            if len(tokens) > 4:
                tokens[1] += ":{}".format(tokens[2])
                del tokens[2]
            elif len(tokens) == 4:
                if tokens[3] != "None":
                    spatialLayers += 1
            else:
                continue

        if spatialLayers > 1:
            QMessageBox.warning(config.iface.mainWindow(), 'Cannot import layer',
                    "Only geopackage layers with single sublayer are supported at the moment",
                    QMessageBox.Ok)
            return

    repos = repository.repos
    if repos:
        dlg = ImportDialog(config.iface.mainWindow(), layer = layer)
        dlg.exec_()
        if dlg.ok:
            setAsRepoLayer(layer)
            repoWatcher.repoChanged.emit(dlg.repo)

    else:
        QMessageBox.warning(config.iface.mainWindow(), 'Cannot import layer',
                "No repositories were found",
                QMessageBox.Ok)
コード例 #7
0
def addLayer(layer):
    if not layer.source().lower().endswith("shp"):
        QtGui.QMessageBox.warning(config.iface.mainWindow(), 'Cannot add layer',
                "Only shapefile layers are supported at the moment",
                QtGui.QMessageBox.Ok)
        return
    repos = localRepos()
    if repos:
        dlg = ImportDialog(config.iface.mainWindow(), layer = layer)
        dlg.exec_()
        if dlg.ok:
            config.iface.messageBar().pushMessage("Layer correctly added to repository",
                                              level = QgsMessageBar.INFO, duration = 4)
            setAsTracked(layer)
            repoWatcher.repoChanged.emit(dlg.repo)

    else:
        QtGui.QMessageBox.warning(config.iface.mainWindow(), 'Cannot add layer',
                "No local repositories were found",
                QtGui.QMessageBox.Ok)
コード例 #8
0
def addLayer(layer):
    if not layer.source().lower().split("|")[0].split(".")[-1] in [
            "geopkg", "gpkg"
    ]:
        QMessageBox.warning(
            config.iface.mainWindow(), 'Cannot add layer',
            "Only geopackage layers are supported at the moment",
            QMessageBox.Ok)
        return
    repos = repository.repos
    if repos:
        dlg = ImportDialog(config.iface.mainWindow(), layer=layer)
        dlg.exec_()
        if dlg.ok:
            setAsRepoLayer(layer)
            repoWatcher.repoChanged.emit(dlg.repo)

    else:
        QMessageBox.warning(config.iface.mainWindow(), 'Cannot add layer',
                            "No repositories were found", QMessageBox.Ok)
コード例 #9
0
def addLayer(layer):
    if not layer.source().lower().endswith("shp"):
        QtGui.QMessageBox.warning(
            config.iface.mainWindow(), 'Cannot add layer',
            "Only shapefile layers are supported at the moment",
            QtGui.QMessageBox.Ok)
        return
    repos = localRepos()
    if repos:
        dlg = ImportDialog(config.iface.mainWindow(), layer=layer)
        dlg.exec_()
        if dlg.ok:
            config.iface.messageBar().pushMessage(
                "Layer correctly added to repository",
                level=QgsMessageBar.INFO,
                duration=4)
            setAsTracked(layer)
            repoWatcher.repoChanged.emit(dlg.repo)

    else:
        QtGui.QMessageBox.warning(config.iface.mainWindow(),
                                  'Cannot add layer',
                                  "No local repositories were found",
                                  QtGui.QMessageBox.Ok)