Ejemplo n.º 1
0
    def add_symbol(self):
        """ This is a simple wrapper calling the worker member function
        with the proper interface widgets.

        """

        data = self._get_data_from_interface()
        if not data:
            return

        # check that symbol is unique and new
        if data["name"] in self._symbolDict:
            logger.error(msg.symbolExistsText % data["name"])
            QMessageBox.critical(None, msg.symbolExistsTitle,
                                 msg.symbolExistsText % data["name"],
                                 QMessageBox.Close)
            return

        if create_new_symbol(self._symbolPath, data):
            self._update_dict(data)
            self._add_symbol_to_tree_widget(data)
            self.availableSymbolsWidget.setDisabled(False)

            # signal main window so it can update the symbol widget to
            # make new symbol available
            self.emit(SIGNAL("symbol_added"), data["name"], data["category"])
Ejemplo n.º 2
0
    def add_symbol(self):
        """ This is a simple wrapper calling the worker member function
        with the proper interface widgets.

        """

        data = self._get_data_from_interface()
        if not data:
            return

        # check that symbol is unique and new
        if data["name"] in self._symbolDict:
            logger.error(msg.symbolExistsText % data["name"])
            QMessageBox.critical(None, msg.symbolExistsTitle,
                                 msg.symbolExistsText % data["name"],
                                 QMessageBox.Close)
            return

        if create_new_symbol(self._symbolPath, data):
            self._update_dict(data)
            self._add_symbol_to_tree_widget(data)
            self.availableSymbolsWidget.setDisabled(False)

            # signal main window so it can update the symbol widget to
            # make new symbol available
            self.emit(SIGNAL("symbol_added"), data["name"], data["category"])
Ejemplo n.º 3
0
    def update_symbol(self):
        """ Updated the information for a custom symbol.

        For robustnes, this slot is implemented via creating
        a completely new symbol definition directory that is
        then replacing the original one.

        """

        if not self._selectedSymbol:
            return

        oldSymbol = self._selectedSymbol
        oldSvgName = self._selectedSymbol["svgName"]
        oldName = self._selectedSymbol["name"]
        oldWidth = int(self._selectedSymbol["width"])

        data = self._get_data_from_interface()

        # if the canvas contains this symbol we can only
        # update if the user changed the category or description
        canUpdate = (data["name"] == oldName) and \
                    (data["svgName"] == oldSvgName) and \
                    (data["width"] == oldWidth)
        if self.parent().canvas_has_symbol(oldName) and not canUpdate:
            QMessageBox.critical(self,
                                 msg.cannotUpdateSymbolTitle,
                                 msg.cannotUpdateSymbolText % oldName,
                                 QMessageBox.Ok)
            return
        else:
            answer = QMessageBox.question(self,
                                          msg.updateSymbolTitle,
                                          msg.updateSymbolText % oldName,
                                          QMessageBox.Ok | QMessageBox.Cancel)

            if answer == QMessageBox.Cancel:
                return

        if data:
            with SymbolTempDir(self._symbolPath) as tempDir:
                if (create_new_symbol(tempDir, data)
                    and remove_symbol(self._symbolPath, oldSvgName)
                    and move_symbol(tempDir + "/" + data["svgName"],
                                    self._symbolPath + "/"
                                    + data["svgName"])):
                    self._update_dict(data)
                    self._update_tree_widget(oldSymbol, data)
                    self._update_frame_data(data)

            # signal main window so it can update the symbol widget to
            # make new symbol available
            self.emit(SIGNAL("symbol_updated"), data["name"], data["category"],
                      oldSymbol["name"], oldSymbol["category"])
Ejemplo n.º 4
0
    def update_symbol(self):
        """ Updated the information for a custom symbol.

        For robustnes, this slot is implemented via creating
        a completely new symbol definition directory that is
        then replacing the original one.

        """

        if not self._selectedSymbol:
            return

        oldSymbol = self._selectedSymbol
        oldSvgName = self._selectedSymbol["svgName"]
        oldName = self._selectedSymbol["name"]
        oldWidth = int(self._selectedSymbol["width"])

        data = self._get_data_from_interface()

        # if the canvas contains this symbol we can only
        # update if the user changed the category or description
        canUpdate = (data["name"] == oldName) and \
                    (data["svgName"] == oldSvgName) and \
                    (data["width"] == oldWidth)
        if self.parent().canvas_has_symbol(oldName) and not canUpdate:
            QMessageBox.critical(self, msg.cannotUpdateSymbolTitle,
                                 msg.cannotUpdateSymbolText % oldName,
                                 QMessageBox.Ok)
            return
        else:
            answer = QMessageBox.question(self, msg.updateSymbolTitle,
                                          msg.updateSymbolText % oldName,
                                          QMessageBox.Ok | QMessageBox.Cancel)

            if answer == QMessageBox.Cancel:
                return

        if data:
            with SymbolTempDir(self._symbolPath) as tempDir:
                if (create_new_symbol(tempDir, data)
                        and remove_symbol(self._symbolPath, oldSvgName)
                        and move_symbol(
                            tempDir + "/" + data["svgName"],
                            self._symbolPath + "/" + data["svgName"])):
                    self._update_dict(data)
                    self._update_tree_widget(oldSymbol, data)
                    self._update_frame_data(data)

            # signal main window so it can update the symbol widget to
            # make new symbol available
            self.emit(SIGNAL("symbol_updated"), data["name"], data["category"],
                      oldSymbol["name"], oldSymbol["category"])