def importClicked(self): ret = QMessageBox.warning( config.iface.mainWindow(), 'Import warning', "Importing a layer will modify the original layer and might cause data loss.\n" "Make sure you have a backup copy of your layer before importing.\n" "Do you want to import the selected layer?", QMessageBox.Yes | QMessageBox.No) if ret == QMessageBox.No: return if self.repo is None: self.repo = repository.repos[self.repoCombo.currentIndex()] if self.layer is None: text = self.layerCombo.currentText() self.layer = layerFromName(text) user, email = config.getUserInfo() if user is None: self.close() return message = self.messageBox.toPlainText() or datetime.now().strftime( "%Y-%m-%d %H_%M_%S") branch = self.branchCombo.currentText() try: self.repo.importgeopkg(self.layer, branch, message, user, email, False) filename, layername = namesFromLayer(self.layer) self.repo.checkoutlayer(filename, layername, ref=branch) self.layer.reload() self.layer.triggerRepaint() except GeoGigException as e: iface.messageBar().pushMessage("Error", str(e), level=QgsMessageBar.CRITICAL, duration=5) self.close() return addTrackedLayer(self.layer, self.repo.url) self.ok = True iface.messageBar().pushMessage( "Layer was correctly added to repository", level=QgsMessageBar.INFO, duration=5) self.close()
def importClicked(self): ret = QMessageBox.warning(config.iface.mainWindow(), 'Import warning', "Importing a layer will modify the original layer and might cause data loss.\n" "Make sure you have a backup copy of your layer before importing.\n" "Do you want to import the selected layer?", QMessageBox.Yes | QMessageBox.No) if ret == QMessageBox.No: return if self.repo is None: self.repo = repository.repos[self.repoCombo.currentIndex()] if self.layer is None: text = self.layerCombo.currentText() self.layer = layerFromName(text) user, email = config.getUserInfo() if user is None: self.close() return message = self.messageBox.toPlainText() or datetime.now().strftime("%Y-%m-%d %H_%M_%S") branch = self.branchCombo.currentText() try: self.repo.importgeopkg(self.layer, branch, message, user, email, False) filename, layername = namesFromLayer(self.layer) self.repo.checkoutlayer(filename, layername, ref = branch) self.layer.reload() self.layer.triggerRepaint() except GeoGigException as e: iface.messageBar().pushMessage("Error", str(e), level=QgsMessageBar.CRITICAL, duration=5) self.close() return addTrackedLayer(self.layer, self.repo.url) self.ok = True iface.messageBar().pushMessage("Layer was correctly added to repository", level=QgsMessageBar.INFO, duration=5) self.close()
def _checkContextMenuInfo(text): layer = layerFromName("points") actions = layeractions._infoActions[layer.id()] assert 2 == len(actions) assert text in actions[0].text().lower()
def _checkLayerHasUntrackedContextMenus(): layer = layerFromName("points") actions = layeractions._actions[layer.id()] assert 1 == len(actions) assert "add" in actions[0].text().lower()
def _checkLayerHasTrackedContextMenus(): layer = layerFromName("points") actions = layeractions._actions[layer.id()] assert 1 < len(actions) assert "commit id" in actions[-1].text().lower()
def _selectLayer(): layer = layerFromName("points") iface.setActiveLayer(layer)
def _checkLayerInProject(): layer = layerFromName("points") assert layer is not None