Exemplo n.º 1
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"])
Exemplo n.º 2
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"])
Exemplo n.º 3
0
    def delete_symbol(self):
        """ This slot deletes the currently selected symbol.
        We pop up a confirmation dialog just to make sure ;)

        """

        # should never occur, but what the heck
        if not self._selectedSymbol:
            return

        name = self._selectedSymbol["name"]
        # if the canvas contains this symbol we can't delete it
        # otherwise warn the user
        if self.parent().canvas_has_symbol(name):
            QMessageBox.question(self,
                                 msg.cannotDeleteSymbolTitle,
                                 msg.cannotDeleteSymbolText % name,
                                 QMessageBox.Ok)
            return
        else:
            answer = QMessageBox.question(self,
                                          msg.deleteSymbolTitle,
                                          msg.deleteSymbolText % name,
                                          QMessageBox.Ok | QMessageBox.Cancel)

            if answer == QMessageBox.Cancel:
                return

        svgName = self._selectedSymbol["svgName"]
        oldName = self._selectedSymbol["name"]
        oldCategory = self._selectedSymbol["category"]
        status = remove_symbol(self._symbolPath, svgName)

        # if we succeeded to remove the symbol from disk
        # lets remove it from the interface and cached database as well
        if status:
            self._delete_symbol_from_database(self._selectedSymbol)
            self.symbolEntryFrame.setVisible(False)
            self._delete_symbol_from_tree_widget(self._selectedSymbol)

            # signal main window so it can update the symbol widget to
            # make new symbol available
            self.emit(SIGNAL("symbol_deleted"), oldName, oldCategory)
Exemplo n.º 4
0
    def delete_symbol(self):
        """ This slot deletes the currently selected symbol.
        We pop up a confirmation dialog just to make sure ;)

        """

        # should never occur, but what the heck
        if not self._selectedSymbol:
            return

        name = self._selectedSymbol["name"]
        # if the canvas contains this symbol we can't delete it
        # otherwise warn the user
        if self.parent().canvas_has_symbol(name):
            QMessageBox.question(self, msg.cannotDeleteSymbolTitle,
                                 msg.cannotDeleteSymbolText % name,
                                 QMessageBox.Ok)
            return
        else:
            answer = QMessageBox.question(self, msg.deleteSymbolTitle,
                                          msg.deleteSymbolText % name,
                                          QMessageBox.Ok | QMessageBox.Cancel)

            if answer == QMessageBox.Cancel:
                return

        svgName = self._selectedSymbol["svgName"]
        oldName = self._selectedSymbol["name"]
        oldCategory = self._selectedSymbol["category"]
        status = remove_symbol(self._symbolPath, svgName)

        # if we succeeded to remove the symbol from disk
        # lets remove it from the interface and cached database as well
        if status:
            self._delete_symbol_from_database(self._selectedSymbol)
            self.symbolEntryFrame.setVisible(False)
            self._delete_symbol_from_tree_widget(self._selectedSymbol)

            # signal main window so it can update the symbol widget to
            # make new symbol available
            self.emit(SIGNAL("symbol_deleted"), oldName, oldCategory)