def publishProject(tree, explorer, catalog):
    layers = qgislayers.getAllLayers()
    dlg = PublishProjectDialog(catalog)
    dlg.exec_()
    if not dlg.ok:
        return
    workspace = dlg.workspace
    groupName = dlg.groupName
    overwrite = dlg.overwrite
    explorer.setProgressMaximum(len(layers), "Publish layers")
    progress = 0
    cat = CatalogWrapper(catalog)
    for layer in layers:
        explorer.setProgress(progress)
        explorer.run(publishLayer,
                     None,
                     [],
                     cat, layer, workspace, overwrite)
        progress += 1
        explorer.setProgress(progress)
    explorer.resetActivity()
    groups = qgislayers.getGroups()
    for group in groups:
        names = [layer.name() for layer in groups[group]]
        try:
            layergroup = catalog.create_layergroup(group, names, names)
            explorer.run(catalog.save, "Create layer group '" + group + "'",
                 [], layergroup)
        except ConflictingDataError, e:
            explorer.setWarning(str(e))
示例#2
0
def checkLayers():
    layers = qgislayers.getAllLayers()
    if len(layers) == 0:
        QtGui.QMessageBox.warning(config.iface.mainWindow(), 'QGIS layers needed',
            "No suitable layers can be found in your current QGIS project.\n"
            "You must open the layers in QGIS to be able to work with them.",
            QtGui.QMessageBox.Ok)
        return False
    return True
示例#3
0
def checkLayers():
    layers = qgislayers.getAllLayers()
    if len(layers) == 0:
        QtGui.QMessageBox.warning(
            iface.mainWindow(), 'QGIS layers needed',
            "No suitable layers can be found in your current QGIS project.\n"
            "You must open the layers in QGIS to be able to work with them.",
            QtGui.QMessageBox.Ok)
        return False
    return True
 def __init__(self, catalog, parent=None):
     super(QtGui.QDialog, self).__init__(parent)
     self.catalog = catalog
     self.layers = qgislayers.getAllLayers()
     self.columns = []
     self.nameBoxes = []
     self.topublish = None
     self.lyr = "Layer"
     self.wrksp = "Workspace"
     self.ow = "Overwrite"
     self.name = "Name"
     self.initGui()
示例#5
0
 def __init__(self, catalog, parent=None):
     super(QDialog, self).__init__(parent)
     self.catalog = catalog
     self.layers = qgislayers.getAllLayers()
     self.columns = []
     self.nameBoxes = []
     self.topublish = None
     self.lyr = "Layer"
     self.wrksp = "Workspace"
     self.ow = "Overwrite"
     self.name = "Name"
     self.style = "Style"
     self.initGui()
def publishProject(tree, explorer, catalog):
    layers = qgislayers.getAllLayers()
    dlg = PublishProjectDialog(catalog)
    dlg.exec_()
    if not dlg.ok:
        return
    workspace = dlg.workspace
    groupName = dlg.groupName
    overwrite = dlg.overwrite
    explorer.setProgressMaximum(len(layers), "Publish layers")
    progress = 0
    cat = CatalogWrapper(catalog)
    for layer in layers:
        explorer.setProgress(progress)
        explorer.run(publishLayer,
                     None,
                     [],
                     cat, layer, workspace, overwrite)
        progress += 1
        explorer.setProgress(progress)
    explorer.resetActivity()
    groups = qgislayers.getGroups()
    for group in groups:
        names = [layer.name() for layer in groups[group][::-1]]
        try:
            layergroup = catalog.create_layergroup(group, names, names, getGroupBounds(groups[group]))
        except ConflictingDataError:
            layergroup = catalog.get_layergroup(group)
            layergroup.dirty.update(layers = names, styles = names)
        explorer.run(catalog.save, "Create layer group '" + group + "'",
                 [], layergroup)

    if groupName is not None:
        names = [layer.name() for layer in layers[::-1]]
        try:
            layergroup = catalog.create_layergroup(groupName, names, names, getGroupBounds(layers))
        except ConflictingDataError:
            layergroup = catalog.get_layergroup(groupName)
            layergroup.dirty.update(layers = names, styles = names)
        explorer.run(catalog.save, "Create global layer group",
                 [], layergroup)
    tree.findAllItems(catalog)[0].refreshContent(explorer)
    explorer.resetActivity()
def publishProject(tree, explorer, catalog):
    layers = qgislayers.getAllLayers()
    dlg = PublishProjectDialog(catalog)
    dlg.exec_()
    if not dlg.ok:
        return
    workspace = dlg.workspace
    groupName = dlg.groupName
    overwrite = dlg.overwrite
    layersAndParams = [(layer, workspace, overwrite) for layer in layers]

    def layersUploaded():
        groups = qgislayers.getGroups()
        for group in groups:
            names = [layer.name() for layer in groups[group][::-1]]
            try:
                layergroup = catalog.create_layergroup(
                    group, names, names, getGroupBounds(groups[group]))
            except ConflictingDataError:
                layergroup = catalog.get_layergroups(group)[0]
                layergroup.dirty.update(layers=names, styles=names)
            explorer.run(catalog.save, "Create layer group '" + group + "'",
                         [], layergroup)

        if groupName is not None:
            names = [layer.name() for layer in layers[::-1]]
            try:
                layergroup = catalog.create_layergroup(groupName, names, names,
                                                       getGroupBounds(layers))
            except ConflictingDataError:
                layergroup = catalog.get_layergroups(groupName)[0]
                layergroup.dirty.update(layers=names, styles=names)
            explorer.run(catalog.save, "Create global layer group", [],
                         layergroup)
        tree.findAllItems(catalog)[0].refreshContent(explorer)
        explorer.resetActivity()

    _publishLayers(catalog, layersAndParams, layersUploaded)
def publishProject(tree, explorer, catalog):
    layers = qgislayers.getAllLayers()
    dlg = PublishProjectDialog(catalog)
    dlg.exec_()
    if not dlg.ok:
        return
    workspace = dlg.workspace
    groupName = dlg.groupName
    overwrite = dlg.overwrite
    layersAndParams = [(layer, workspace, overwrite) for layer in layers]

    def layersUploaded():
        groups = qgislayers.getGroups()
        for group in groups:
            names = [layer.name() for layer in groups[group][::-1]]
            try:
                layergroup = catalog.create_layergroup(group, names, names, getGroupBounds(groups[group]))
            except ConflictingDataError:
                layergroup = catalog.get_layergroups(group)[0]
                layergroup.dirty.update(layers = names, styles = names)
            explorer.run(catalog.save, "Create layer group '" + group + "'",
                     [], layergroup)

        if groupName is not None:
            names = [layer.name() for layer in layers[::-1]]
            try:
                layergroup = catalog.create_layergroup(groupName, names, names, getGroupBounds(layers))
            except ConflictingDataError:
                layergroup = catalog.get_layergroups(groupName)[0]
                layergroup.dirty.update(layers = names, styles = names)
            explorer.run(catalog.save, "Create global layer group",
                     [], layergroup)
        tree.findAllItems(catalog)[0].refreshContent(explorer)
        explorer.resetActivity()

    _publishLayers(catalog, layersAndParams, layersUploaded)
示例#9
0
    def initGui(self):
        verticalLayout = QtGui.QVBoxLayout()
        buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
                                           | QtGui.QDialogButtonBox.Close)
        self.okButton = buttonBox.button(QtGui.QDialogButtonBox.Ok)
        self.cancelButton = buttonBox.button(QtGui.QDialogButtonBox.Close)
        self.setWindowTitle('Create style from layer')

        horizontalLayout = QtGui.QHBoxLayout()
        horizontalLayout.setMargin(0)
        layerLabel = QtGui.QLabel('Layer')
        layerLabel.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum,
                              QtGui.QSizePolicy.Fixed))
        self.layerBox = QtGui.QComboBox()
        self.alllayers = [layer.name() for layer in layers.getAllLayers()]
        self.layerBox.addItems(self.alllayers)
        self.layerBox.setMinimumWidth(250)
        horizontalLayout.addWidget(layerLabel)
        horizontalLayout.addWidget(self.layerBox)
        verticalLayout.addLayout(horizontalLayout)

        horizontalLayout = QtGui.QHBoxLayout()
        horizontalLayout.setMargin(0)
        nameLabel = QtGui.QLabel('Name')
        nameLabel.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum,
                              QtGui.QSizePolicy.Fixed))
        defaultname = ''
        if len(self.alllayers) > 0:
            defaultname = xmlNameFixUp(self.alllayers[0])
        self.nameBox = GSNameWidget(namemsg='',
                                    name=defaultname,
                                    nameregex=xmlNameRegex(),
                                    nameregexmsg=xmlNameRegexMsg(),
                                    names=self.styles,
                                    unique=False)
        self.nameBox.setMinimumWidth(250)
        horizontalLayout.addWidget(nameLabel)
        horizontalLayout.addWidget(self.nameBox)
        verticalLayout.addLayout(horizontalLayout)

        self.groupBox = QtGui.QGroupBox()
        self.groupBox.setTitle("")
        self.groupBox.setLayout(verticalLayout)

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.groupBox)
        layout.addWidget(buttonBox)

        self.setLayout(layout)

        buttonBox.accepted.connect(self.okPressed)
        buttonBox.rejected.connect(self.cancelPressed)

        self.layerBox.currentIndexChanged[str].connect(self.updateNameBox)
        self.nameBox.nameValidityChanged.connect(self.okButton.setEnabled)
        self.nameBox.overwritingChanged.connect(self.updateButtons)
        self.okButton.setEnabled(self.nameBox.isValid())
        self.updateButtons(self.nameBox.overwritingName())

        self.resize(400, 150)
示例#10
0
    def initGui(self):                         
        verticalLayout = QtGui.QVBoxLayout()                                
        buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Close)
        self.okButton = buttonBox.button(QtGui.QDialogButtonBox.Ok)
        self.cancelButton = buttonBox.button(QtGui.QDialogButtonBox.Close)
        self.setWindowTitle('Create style from layer')
        
        horizontalLayout = QtGui.QHBoxLayout()
        horizontalLayout.setMargin(0)
        layerLabel = QtGui.QLabel('Layer')
        layerLabel.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum,
                              QtGui.QSizePolicy.Fixed))
        self.layerBox = QtGui.QComboBox()
        self.alllayers = [layer.name() for layer in layers.getAllLayers()]
        self.layerBox.addItems(self.alllayers)
        self.layerBox.setMinimumWidth(250)
        horizontalLayout.addWidget(layerLabel)
        horizontalLayout.addWidget(self.layerBox)
        verticalLayout.addLayout(horizontalLayout)
               
        horizontalLayout = QtGui.QHBoxLayout()
        horizontalLayout.setMargin(0)
        nameLabel = QtGui.QLabel('Name')
        nameLabel.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum,
                              QtGui.QSizePolicy.Fixed))
        defaultname = ''
        if len(self.alllayers) > 0:
            defaultname = xmlNameFixUp(self.alllayers[0])
        self.nameBox = GSNameWidget(
            namemsg='',
            name=defaultname,
            nameregex=xmlNameRegex(),
            nameregexmsg=xmlNameRegexMsg(),
            names=self.styles,
            unique=False)
        self.nameBox.setMinimumWidth(250)
        horizontalLayout.addWidget(nameLabel)
        horizontalLayout.addWidget(self.nameBox)
        verticalLayout.addLayout(horizontalLayout)
        
        self.groupBox = QtGui.QGroupBox()
        self.groupBox.setTitle("")
        self.groupBox.setLayout(verticalLayout)
        
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.groupBox) 
        layout.addWidget(buttonBox)
              
        self.setLayout(layout)

        buttonBox.accepted.connect(self.okPressed)
        buttonBox.rejected.connect(self.cancelPressed)

        self.layerBox.currentIndexChanged[str].connect(self.updateNameBox)
        self.nameBox.nameValidityChanged.connect(self.okButton.setEnabled)
        self.nameBox.overwritingChanged.connect(self.updateButtons)
        self.okButton.setEnabled(self.nameBox.isValid())
        self.updateButtons(self.nameBox.overwritingName())
        
        self.resize(400,150)