Exemple #1
0
    def deploy_projects(self, all_projects=False):
        self.write_config()

        self.progressLabel.show()

        datazipfile = None

        self.data_depolyed_folders = []
        for projectconfig in self.get_project_depoly_settings(all_projects=all_projects).values():
            # Gross but quicker then threading at the moment.
            QApplication.instance().processEvents()
            # Fix the path to use the global location, or the roam_srv if that isn't set.
            projectconfig['path'] = self.resolve_path(projectconfig['path'])
            self.projects[projectconfig['id']].save(update_version=True, reset_save_point=True)
            if projectconfig['path'] not in self.data_depolyed_folders and self.includeDataCheck.isChecked():
                if not datazipfile:
                    datazipfile = self.make_zip()

                self.logger.info("Deploying data for location {}".format(projectconfig['path']))
                self.deploy_data(projectconfig, datazipfile)
                self.data_depolyed_folders.append(projectconfig['path'])

            self.deploy_project(projectconfig)
            self.logger.info("Updating project.config")
        self.progressLabel.hide()
        self.reload_projects()

        self.write_config()
    def __init__(self, parent=None):
        super(EditorWidgetTms, self).__init__(parent)
        self.setupUi(self)
        self.tms_validator = LineEditColorValidator(self.txtUrl, 'http[s]?://.+', error_tooltip='http{s}://any_text/{z}/{x}/{y}/')
        self.txtCrsId.setValidator(QIntValidator())
        self.txtPostgisCrsId.setValidator(QIntValidator())

        QApplication.instance().focusChanged.connect(self.focus_changed)
Exemple #3
0
    def __init__(self, parent=None):
        super(EditorWidgetTms, self).__init__(parent)
        self.setupUi(self)
        self.tms_validator = LineEditColorValidator(
            self.txtUrl,
            'http[s]?://.+',
            error_tooltip='http{s}://any_text/{z}/{x}/{y}/')
        self.txtCrsId.setValidator(QIntValidator())
        self.txtPostgisCrsId.setValidator(QIntValidator())

        QApplication.instance().focusChanged.connect(self.focus_changed)
def reload_style(path):
    # Some applications will remove a file and rewrite it.  QFileSystemWatcher will
    # ignore the file if the file handle goes away so we have to keep adding it.
    watch.removePaths(watch.files())
    watch.addPath(path)
    with open(path, "r") as f:
        stylesheet = f.read()
        # Update the image paths to use full paths. Fixes image loading in styles
        path = os.path.dirname(path).replace("\\", "/")
        stylesheet = re.sub(r"url\((.*?)\)", r'url("{}/\1")'.format(path), stylesheet)
        QApplication.instance().setStyleSheet(stylesheet)
Exemple #5
0
def showException(type, value, tb, msg, messagebar=False):
    if msg is None:
        msg = QCoreApplication.translate(
            'Python', 'An error has occurred while executing Python code:')

    logmessage = ''
    for s in traceback.format_exception(type, value, tb):
        logmessage += s.decode('utf-8', 'replace') if hasattr(s,
                                                              'decode') else s

    title = QCoreApplication.translate('Python', 'Python error')
    QgsMessageLog.logMessage(logmessage, title)

    try:
        blockingdialog = QApplication.instance().activeModalWidget()
        window = QApplication.instance().activeWindow()
    except:
        blockingdialog = QApplication.activeModalWidget()
        window = QApplication.activeWindow()

    # Still show the normal blocking dialog in this case for now.
    if blockingdialog or not window or not messagebar or not iface:
        open_stack_dialog(type, value, tb, msg)
        return

    bar = iface.messageBar() if iface else None

    # If it's not the main window see if we can find a message bar to report the error in
    if not window.objectName() == "QgisApp":
        widgets = window.findChildren(QgsMessageBar)
        if widgets:
            # Grab the first message bar for now
            bar = widgets[0]

    item = bar.currentItem()
    if item and item.property("Error") == msg:
        # Return of we already have a message with the same error message
        return

    widget = bar.createMessage(
        title, msg + " " + QCoreApplication.translate(
            "Python", "See message log (Python Error) for more details."))
    widget.setProperty("Error", msg)
    stackbutton = QPushButton(
        QCoreApplication.translate("Python", "Stack trace"),
        pressed=functools.partial(open_stack_dialog, type, value, tb, msg))
    button = QPushButton(QCoreApplication.translate("Python",
                                                    "View message log"),
                         pressed=show_message_log)
    widget.layout().addWidget(stackbutton)
    widget.layout().addWidget(button)
    bar.pushWidget(widget, Qgis.Warning)
Exemple #6
0
def showException(type, value, tb, msg, messagebar=False):
    if msg is None:
        msg = QCoreApplication.translate("Python", "An error has occurred while executing Python code:")

    logmessage = ""
    for s in traceback.format_exception(type, value, tb):
        logmessage += s.decode("utf-8", "replace") if hasattr(s, "decode") else s

    title = QCoreApplication.translate("Python", "Python error")
    QgsMessageLog.logMessage(logmessage, title)

    try:
        blockingdialog = QApplication.instance().activeModalWidget()
        window = QApplication.instance().activeWindow()
    except:
        blockingdialog = QApplication.activeModalWidget()
        window = QApplication.activeWindow()

    # Still show the normal blocking dialog in this case for now.
    if blockingdialog or not window or not messagebar or not iface:
        open_stack_dialog(type, value, tb, msg)
        return

    bar = iface.messageBar()

    # If it's not the main window see if we can find a message bar to report the error in
    if not window.objectName() == "QgisApp":
        widgets = window.findChildren(QgsMessageBar)
        if widgets:
            # Grab the first message bar for now
            bar = widgets[0]

    item = bar.currentItem()
    if item and item.property("Error") == msg:
        # Return of we already have a message with the same error message
        return

    widget = bar.createMessage(
        title, msg + " " + QCoreApplication.translate("Python", "See message log (Python Error) for more details.")
    )
    widget.setProperty("Error", msg)
    stackbutton = QPushButton(
        QCoreApplication.translate("Python", "Stack trace"),
        pressed=functools.partial(open_stack_dialog, type, value, tb, msg),
    )
    button = QPushButton(QCoreApplication.translate("Python", "View message log"), pressed=show_message_log)
    widget.layout().addWidget(stackbutton)
    widget.layout().addWidget(button)
    bar.pushWidget(widget, QgsMessageBar.WARNING)
 def closeTableAttribute():
     layer_id = self.alert_id
     widgets = QApplication.instance().allWidgets()
     for tb in filter(
             lambda w: isinstance(w, QDialog) and layer_id in w.
             objectName(), widgets):
         tb.close()
Exemple #8
0
    def __import_data(self):
        assert(self.project)
        dir_ = QFileDialog.getExistingDirectory(
            None,
            u"Data directory",
            QgsProject.instance().readEntry("albion", "last_dir", "")[0],
            QFileDialog.ShowDirsOnly | QFileDialog.DontUseNativeDialog
        )
        if not dir_:
            return
        QgsProject.instance().writeEntry("albion", "last_dir", dir_),

        progressMessageBar = self.__iface.messageBar().createMessage(
            "Loading {}...".format(dir_)
        )
        progress = QProgressBar()
        progress.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        progressMessageBar.layout().addWidget(progress)
        self.__iface.messageBar().pushWidget(progressMessageBar)

        self.project.import_data(dir_, ProgressBar(progress))
        #self.project.triangulate()
        self.project.create_section_view_0_90(4)

        self.__iface.messageBar().clearWidgets()

        collar = QgsProject.instance().mapLayersByName("collar")
        if len(collar):
            collar[0].reload()
            collar[0].updateExtents()
            self.__iface.setActiveLayer(collar[0])
            QApplication.instance().processEvents()
            while self.__iface.mapCanvas().isDrawing():
                QApplication.instance().processEvents()
            self.__iface.zoomToActiveLayer()

        self.__iface.actionSaveProject().trigger()

        self.__viewer3d.widget().resetScene(self.project)
        self.__current_section.clear()
        self.__current_section.addItems(self.project.sections())
    def _manage_attribute_table(self):
        """ If configured, disable button "Update all" from attribute table """

        disable = tools_gw.get_config_parser(
            'system',
            'disable_updateall_attributetable',
            "user",
            "init",
            prefix=False)
        if tools_os.set_boolean(disable, False):
            tools_gw.connect_signal(QApplication.instance().focusChanged,
                                    self._manage_focus_changed, 'load_project',
                                    'manage_attribute_table_focusChanged')
Exemple #10
0
 def barres(capa):
     try:
         QApplication.instance().setOverrideCursor(Qt.WaitCursor)
         from moduls.QvPlotly import QvPlot, QvChart
         regs = dict()
         for f in capa.getFeatures():
             regs[f['CODI']] = (f['DESCRIPCIO'], f['RESULTAT'])
         lista = OrderedDict(sorted(regs.items()))
         zona = QvDiagrama.capaAmbDiagrama(capa).lower()
         pl = QvPlot.barres([elem[1] for elem in lista.values()],
                            [elem[0] for elem in lista.values()],
                            titol='Capa ' + capa.name() +
                            ' - Diagrama per ' + zona,
                            horitzontal=True)
         vis = QvChart.visorGrafic(pl)
         if zona == 'barri':
             len = max(vis.midaX, vis.midaY)
             vis.resize(len, len)
         return vis
     except Exception as e:
         print(str(e))
         return None
     finally:
         QApplication.instance().restoreOverrideCursor()
    def __init__(self, iface):
        self.iface = iface
        self.plugin_dir = os.path.dirname(__file__)

        self.windowTitle = "3Di Modeller Interface - Powered by QGIS"

        self.app = QApplication.instance()
        self.QApp = QCoreApplication.instance()

        if self.QApp is None:
            self.QApp = QApplication(sys.argv)

        self.QApp.startingUp()
        self.QApp.processEvents()
        self.app.startDragTime()

        self.iface.initializationCompleted.connect(self.customization)
        qApp.processEvents()

        self.applyStyle()
Exemple #12
0
 def set_busy_cursor(self):
     """Sets the cursor to a busy cursor."""
     if not self.cursor_busy:
         QApplication.instance().setOverrideCursor(Qt.WaitCursor)
         self.cursor_busy = True
Exemple #13
0
def set_arrow_cursor():
    QApplication.instance().setOverrideCursor(Qt.ArrowCursor)
Exemple #14
0
 def msgProces(self, txt):
     QApplication.instance().restoreOverrideCursor()
     self.msgInfo(txt)
     QApplication.instance().setOverrideCursor(Qt.WaitCursor)
Exemple #15
0
def set_wait_cursor():
    QApplication.instance().setOverrideCursor(Qt.WaitCursor)
Exemple #16
0
 def msgContinuarProces(self, txt):
     QApplication.instance().restoreOverrideCursor()
     res = QMessageBox.question(self, 'Atenció', txt + "\n\nVol continuar?")
     QApplication.instance().setOverrideCursor(Qt.WaitCursor)
     return res == QMessageBox.Yes
Exemple #17
0
 def pause(self):
     QApplication.instance().setOverrideCursor(Qt.WaitCursor)
     self.setDisabled(True)
Exemple #18
0
 def restore_cursor(self):
     """Sets the cursor to a busy cursor."""
     if self.cursor_busy:
         QApplication.instance().restoreOverrideCursor()
         self.cursor_busy = False
Exemple #19
0
 def play(self):
     self.setDisabled(False)
     QApplication.instance().restoreOverrideCursor()