当前位置: 首页>>代码示例>>Python>>正文


Python QMap.remove方法代码示例

本文整理汇总了Python中pyqtcore.QMap.remove方法的典型用法代码示例。如果您正苦于以下问题:Python QMap.remove方法的具体用法?Python QMap.remove怎么用?Python QMap.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyqtcore.QMap的用法示例。


在下文中一共展示了QMap.remove方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: constructAdditionalTable

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]
 def constructAdditionalTable(self, props, propOrder):
     tableString = QString()
     unhandledProps = QMap(props)
     # Remove handled properties
     for i in range(0, propOrder.size()):
         unhandledProps.remove(propOrder[i])
     
     # Construct the Lua string
     if (unhandledProps.size() > 0) :
         tableString = "{"
         for i in unhandledProps:
             tableString = "%s%s=%s,"%tableString, i[0], i[1]
         
         tableString = "%s}"%tableString
     
     return tableString
开发者ID:theall,项目名称:Python-Tiled,代码行数:18,代码来源:tengineplugin.py

示例2: QtButtonPropertyBrowserPrivate

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]
class QtButtonPropertyBrowserPrivate():
    def __init__(self):
        self.q_ptr = None
        self.WidgetItem = WidgetItem()
        self.m_indexToItem = QMap()
        self.m_itemToIndex = QMap()
        self.m_widgetToItem = QMap()
        self.m_buttonToItem = QMap()
        self.m_mainLayout = None
        self.m_children = QList()
        self.m_recreateQueue = QList()

    def createEditor(self, property, parent):
        return self.q_ptr.createEditor(property, parent)

    def createButton(self, parent=None):
        button = QToolButton(parent)
        button.setCheckable(True)
        button.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed))
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        button.setArrowType(Qt.DownArrow)
        button.setIconSize(QSize(3, 16))
        ###
        #QIcon icon
        #icon.addPixmap(self.style().standardPixmap(QStyle.SP_ArrowDown), QIcon.Normal, QIcon.Off)
        #icon.addPixmap(self.style().standardPixmap(QStyle.SP_ArrowUp), QIcon.Normal, QIcon.On)
        #button.setIcon(icon)
        ###
        return button

    def gridRow(self, item):
        siblings = QList()
        if (item.parent):
            siblings = item.parent.children
        else:
            siblings = self.m_children

        row = 0
        for sibling in siblings:
            if (sibling == item):
                return row
            row += self.gridSpan(sibling)

        return -1

    def gridSpan(self, item):
        if (item.container and item.expanded):
            return 2
        return 1

    def init(self, parent):
        self.m_mainLayout = QGridLayout()
        parent.setLayout(self.m_mainLayout)
        item = QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding)
        self.m_mainLayout.addItem(item, 0, 0)

    def slotEditorDestroyed(self):
        editor = self.q_ptr.sender()
        if (not editor):
            return
        if not self.m_widgetToItem.get(editor):
            return
        self.m_widgetToItem[editor].widget = 0
        self.m_widgetToItem.remove(editor)

    def slotUpdate(self):
        for item in self.m_recreateQueue:
            parent = item.parent
            w = 0
            l = 0
            oldRow = self.gridRow(item)
            if (parent):
                w = parent.container
                l = parent.layout
            else:
                w = self.q_ptr
                l = self.m_mainLayout

            span = 1
            if (not item.widget and not item.widgetLabel):
                span = 2
            item.label = QLabel(w)
            item.label.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
            l.addWidget(item.label, oldRow, 0, 1, span)

            self.updateItem(item)

        self.m_recreateQueue.clear()

    def setExpanded(self, item, expanded):
        if (item.expanded == expanded):
            return

        if (not item.container):
            return

        item.expanded = expanded
        row = self.gridRow(item)
        parent = item.parent
        l = 0
#.........这里部分代码省略.........
开发者ID:theall,项目名称:QtPropertyBrowserV2.6-for-pyqt5,代码行数:103,代码来源:qtbuttonpropertybrowser.py

示例3: VariantEditorFactory

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]
class VariantEditorFactory(QtVariantEditorFactory):
    def __init__(self, parent = None):
        super().__init__(parent)

        self.mCreatedEditors = QMapList()
        self.mEditorToProperty = QMap()

    def __del__(self):
        self.mEditorToProperty.clear()

    def connectPropertyManager(self, manager):
        manager.valueChangedSignal.connect(self.slotPropertyChanged)
        manager.attributeChangedSignal.connect(self.slotPropertyAttributeChanged)
        super().connectPropertyManager(manager)

    def createEditor(self, manager, property, parent):
        type = manager.propertyType(property)
        if (type == VariantPropertyManager.filePathTypeId()):
            editor = FileEdit(parent)
            editor.setFilePath(manager.value(property))
            editor.setFilter(manager.attributeValue(property, "filter"))
            self.mCreatedEditors[property].append(editor)
            self.mEditorToProperty[editor] = property
            editor.filePathChanged.connect(self.slotSetValue)
            editor.destroyed.connect(self.slotEditorDestroyed)
            return editor

        editor = super().createEditor(manager, property, parent)
        if (type == QVariant.String):
            # Add support for "suggestions" attribute that adds a QCompleter to the QLineEdit
            suggestions = manager.attributeValue(property, "suggestions")
            if suggestions and len(suggestions)>0:
                lineEdit = editor
                if lineEdit:
                    completer = QCompleter(suggestions, lineEdit)
                    completer.setCaseSensitivity(Qt.CaseInsensitive)
                    lineEdit.setCompleter(completer)
        return editor

    def disconnectPropertyManager(self, manager):
        manager.valueChangedSignal.disconnect(self.slotPropertyChanged)
        manager.attributeChangedSignal.disconnect(self.slotPropertyAttributeChanged)
        super().disconnectPropertyManager(manager)

    def slotPropertyChanged(self, property, value):
        if (not self.mCreatedEditors.contains(property)):
            return
        editors = self.mCreatedEditors[property]
        for itEditor in editors:
            itEditor.setFilePath(value.toString())

    def slotPropertyAttributeChanged(self, property, attribute, value):
        if (not self.mCreatedEditors.contains(property)):
            return
        if (attribute != "filter"):
            return
        editors = self.mCreatedEditors[property]
        for itEditor in editors:
            itEditor.setFilter(value.toString())

    def slotSetValue(self, value):
        object = self.sender()
        itEditor = self.mEditorToProperty.constBegin()
        while (itEditor != self.mEditorToProperty.constEnd()):
            if (itEditor.key() == object):
                property = itEditor.value()
                manager = self.propertyManager(property)
                if (not manager):
                    return
                manager.setValue(property, value)
                return

            itEditor += 1

    def slotEditorDestroyed(self, object):
        for itEditor in self.mEditorToProperty:
            if (itEditor.key() == object):
                editor = itEditor.key()
                property = itEditor.value()
                self.mEditorToProperty.remove(editor)
                self.mCreatedEditors[property].removeAll(editor)
                if (self.mCreatedEditors[property].isEmpty()):
                    self.mCreatedEditors.remove(property)
                return
开发者ID:theall,项目名称:Python-Tiled,代码行数:86,代码来源:varianteditorfactory.py

示例4: DecoratedDoublePropertyManager

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]
class DecoratedDoublePropertyManager(QtDoublePropertyManager):
    prefixChangedSignal = pyqtSignal(QtProperty, str)
    suffixChangedSignal = pyqtSignal(QtProperty, str)
    class Data:
        prefix = ''
        suffix = ''

    def __init__(self, parent=None):
        super().__init__(parent)

        self.propertyToData = QMap()

    def __del__(self):
        pass

    def prefix(self, property):
        if (not self.propertyToData.contains(property)):
            return ''
        return self.propertyToData[property].prefix

    def suffix(self, property):
        if (not self.propertyToData.contains(property)):
            return ''
        return self.propertyToData[property].suffix

    def setPrefix(self, property, prefix):
        if (not self.propertyToData.contains(property)):
            return

        data = self.propertyToData[property]
        if (data.prefix == prefix):
            return

        data.prefix = prefix
        self.propertyToData[property] = data

        self.propertyChangedSignal.emit(property)
        self.suffixChangedSignal.emit(property, prefix)

    def setSuffix(self, property, suffix):
        if (not self.propertyToData.contains(property)):
            return

        data = self.propertyToData[property]
        if (data.suffix == suffix):
            return

        data.suffix = suffix
        self.propertyToData[property] = data

        self.propertyChangedSignal.emit(property)
        self.suffixChangedSignal.emit(property, suffix)

    def valueText(self, property):
        text = super().valueText(property)
        if (not self.propertyToData.contains(property)):
            return text

        data = self.propertyToData[property]
        text = data.prefix + text + data.suffix

        return text

    def initializeProperty(self, property):
        self.propertyToData[property] = DecoratedDoublePropertyManager.Data()
        super().initializeProperty(property)

    def uninitializeProperty(self, property):
        self.propertyToData.remove(property)
        super().uninitializeProperty(property)
开发者ID:theall,项目名称:QtPropertyBrowserV2.6-for-pyqt5,代码行数:72,代码来源:decoration.py

示例5: DecoratedDoubleSpinBoxFactory

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]
class DecoratedDoubleSpinBoxFactory(QtAbstractEditorFactory):

    def __init__(self, parent=None):
        super(DecoratedDoubleSpinBoxFactory, self).__init__(parent)

        self.propertyToData = QMap()
        # We delegate responsibilities for QtDoublePropertyManager, which is a base class
        #   of DecoratedDoublePropertyManager to appropriate 
        self.originalFactory = QtDoubleSpinBoxFactory(self)
        self.createdEditors = QMapList()
        self.editorToProperty = QMap()

    # not need to delete editors because they will be deld by originalFactory in its destructor
    def __del__(self):
        pass

    def connectPropertyManager(self, manager):
        self.originalFactory.addPropertyManager(manager)
        manager.prefixChangedSignal.connect(self.slotPrefixChanged)
        manager.suffixChangedSignal.connect(self.slotSuffixChanged)

    def createEditor(self, manager, property, parent):
        base = self.originalFactory
        w = base.findEditor(property, parent)
        if (not w):
            return 0

        spinBox = w
        if (not spinBox):
            return 0

        spinBox.setPrefix(manager.prefix(property))
        spinBox.setSuffix(manager.suffix(property))

        self.createdEditors[property].append(spinBox)
        self.editorToProperty[spinBox] = property

        return spinBox

    def disconnectPropertyManager(self, manager):
        self.originalFactory.removePropertyManager(manager)
        manager.prefixChangedSignal.disconnect(self.slotPrefixChanged)
        manager.suffixChangedSignal.disconnect(self.slotSuffixChanged)

    def slotPrefixChanged(self, property, prefix):
        if (not self.createdEditors.contains(property)):
            return

        manager = self.propertyManager(property)
        if (not manager):
            return

        editors = self.createdEditors[property]
        for editor in editors:
            editor.setPrefix(prefix)

    def slotSuffixChanged(self, property, prefix):
        if (not self.createdEditors.contains(property)):
            return

        manager = self.propertyManager(property)
        if (not manager):
            return

        editors = self.createdEditors[property]
        for editor in editors:
            editor.setSuffix(prefix)

    def slotEditorDestroyed(self, object):
        property = self.editorToProperty.get(object)
        if property:
            editor = object
            self.editorToProperty.remove(editor)
            self.createdEditors[property].removeAll(editor)
            if (self.createdEditors[property].isEmpty()):
                self.createdEditors.remove(property)
            return
开发者ID:theall,项目名称:QtPropertyBrowserV2.6-for-pyqt5,代码行数:79,代码来源:decoration.py

示例6: VariantPropertyManager

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]

#.........这里部分代码省略.........

        super().__init__(parent)
        self.mSuggestionsAttribute = "suggestions"

    def value(self, property):
        if (self.mValues.contains(property)):
            return self.mValues[property].value
        return super().value(property)

    def valueType(self, propertyType):
        if (propertyType == VariantPropertyManager.filePathTypeId()):
            return QVariant.String
        return super().valueType(propertyType)

    def isPropertyTypeSupported(self, propertyType):
        if (propertyType == VariantPropertyManager.filePathTypeId()):
            return True
        return super().isPropertyTypeSupported(propertyType)

    def attributes(self, propertyType):
        if (propertyType == VariantPropertyManager.filePathTypeId()):
            attr = QStringList()
            attr.append("filter")
            return attr

        return super().attributes(propertyType)

    def attributeType(self, propertyType, attribute):
        if (propertyType == VariantPropertyManager.filePathTypeId()):
            if (attribute == "filter"):
                return QVariant.String
            return 0

        return super().attributeType(propertyType, attribute)

    def attributeValue(self, property, attribute):
        if (self.mValues.contains(property)):
            if (attribute == "filter"):
                return self.mValues[property].filter
            return QVariant()

        if (attribute == self.mSuggestionsAttribute and self.mSuggestions.contains(property)):
            return self.mSuggestions[property]
        return super().attributeValue(property, attribute)

    def filePathTypeId():
        return VariantPropertyManager.TYPEID_FILEPATH

    def setValue(self, property, val):
        if (self.mValues.contains(property)):
            if type(val) != str:
                return
            s = val
            d = self.mValues[property]
            if (d.value == s):
                return
            d.value = s
            self.mValues[property] = d
            self.propertyChangedSignal.emit(property)
            self.valueChangedSignal.emit(property, s)
            return

        super().setValue(property, val)

    def setAttribute(self, property, attribute, val):
        if (self.mValues.contains(property)):
            if (attribute == "filter"):
                if type(val) != str:
                    return
                s = val
                d = self.mValues[property]
                if (d.filter == s):
                    return
                d.filter = s
                self.mValues[property] = d
                self.attributeChangedSignal.emit(property, attribute, s)

            return

        if (attribute == self.mSuggestionsAttribute and self.mSuggestions.contains(property)):
            self.mSuggestions[property] = val
        super().setAttribute(property, attribute, val)

    def valueText(self, property):
        if (self.mValues.contains(property)):
            return self.mValues[property].value
        return super().valueText(property)

    def initializeProperty(self, property):
        tp = self.propertyType(property)
        if (tp == VariantPropertyManager.filePathTypeId()):
            self.mValues[property] = VariantPropertyManager.Data()
        elif tp == QVariant.String:
            self.mSuggestions[property] = QStringList()
        super().initializeProperty(property)

    def uninitializeProperty(self, property):
        self.mValues.remove(property)
        self.mSuggestions.remove(property)
        super().uninitializeProperty(property)
开发者ID:theall,项目名称:Python-Tiled,代码行数:104,代码来源:variantpropertymanager.py

示例7: QtTreePropertyBrowserPrivate

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]

#.........这里部分代码省略.........

    def hasValue(self,item):
        browserItem = self.m_itemToIndex.get(item)
        if browserItem:
            return browserItem.property().hasValue()
        return False

    def propertyInserted(self, index, afterIndex):
        afterItem = self.m_indexToItem.get(afterIndex)
        parentItem = self.m_indexToItem.get(index.parent())

        newItem = 0
        if (parentItem):
            newItem = QTreeWidgetItem(parentItem, afterItem)
        else:
            newItem = QTreeWidgetItem(self.m_treeWidget, afterItem)

        self.m_itemToIndex[newItem] = index
        self.m_indexToItem[index] = newItem

        newItem.setFlags(newItem.flags() | Qt.ItemIsEditable)
        newItem.setExpanded(True)

        self.updateItem(newItem)

    def propertyRemoved(self, index):
        item = self.m_indexToItem.get(index)

        if (self.m_treeWidget.currentItem() == item):
            self.m_treeWidget.setCurrentItem(None)

        parent = item.parent()
        if parent:
            parent.removeChild(item)
        else:
            treeWidget = item.treeWidget()
            treeWidget.takeTopLevelItem(treeWidget.indexOfTopLevelItem(item))
        self.m_indexToItem.remove(index)
        self.m_itemToIndex.remove(item)
        self.m_indexToBackgroundColor.remove(index)

    def propertyChanged(self, index):
        item = self.m_indexToItem.get(index)
        self.updateItem(item)

    def treeWidget(self):
        return self.m_treeWidget

    def markPropertiesWithoutValue(self):
        return self.m_markPropertiesWithoutValue

    def updateItem(self, item):
        property = self.m_itemToIndex[item].property()
        expandIcon = QIcon()
        if (property.hasValue()):
            toolTip = property.toolTip()
            if len(toolTip) <= 0:
                toolTip = property.displayText()
            item.setToolTip(1, toolTip)
            item.setIcon(1, property.valueIcon())
            if len(property.displayText())<=0:
                item.setText(1, property.valueText())
            else:
                item.setText(1, property.displayText())
        elif self.markPropertiesWithoutValue() and not self.m_treeWidget.rootIsDecorated():
            expandIcon = self.m_expandIcon
开发者ID:theall,项目名称:QtPropertyBrowserV2.6-for-pyqt5,代码行数:70,代码来源:qttreepropertybrowser.py

示例8: QtPropertyEditorDelegate

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]
class QtPropertyEditorDelegate(QItemDelegate):
    def __init__(self, parent=None):
        super(QtPropertyEditorDelegate, self).__init__(parent)

        self.m_editorPrivate = 0
        self.m_editedItem = 0
        self.m_editedWidget = 0
        self.m_disablePainting = False
        self.m_propertyToEditor = QMap()
        self.m_editorToProperty = QMap()

    def setEditorPrivate(self,editorPrivate):
        self.m_editorPrivate = editorPrivate

    def setModelData(self,pt_widget,pt_QAbstractItemModel, modelIndex):
        pass

    def setEditorData(self, pt_widget, modelIndex):
        pass

    def editedItem(self):
        return self.m_editedItem

    def indentation(self,index):
        if (not self.m_editorPrivate):
            return 0

        item = self.m_editorPrivate.indexToItem(index)
        indent = 0
        while (item.parent()):
            item = item.parent()
            indent += 1
        if (self.m_editorPrivate.treeWidget().rootIsDecorated()):
            indent += 1
        return indent * self.m_editorPrivate.treeWidget().indentation()

    def slotEditorDestroyed(self, object):
        return
        if object:
            hv = object.property('hash_value')
            for x in self.m_editorToProperty:
                if x[0].hash_value==hv:
                    self.m_propertyToEditor.remove(x)
                    self.m_editorToProperty.erase(x)
                    break
            if (self.m_editedWidget.hash_value == hv):
                self.m_editedWidget = 0
                self.m_editedItem = 0

    def destroyEditor(self, editor, index):
        if editor:
            hv = editor.property('hash_value')
            for x in self.m_editorToProperty:
                if x[0].hash_value==hv:
                    self.m_propertyToEditor.remove(x)
                    self.m_editorToProperty.erase(x)
                    break
            if (self.m_editedWidget.hash_value == hv):
                self.m_editedWidget = 0
                self.m_editedItem = 0
            #editor.deleteLater()

    def closeEditor(self, property):
        pass

    def createEditor(self, parent,pt_QStyleOptionViewItem, index):
        if index.column() == 1 and self.m_editorPrivate:
            property = self.m_editorPrivate.indexToProperty(index)
            item = self.m_editorPrivate.indexToItem(index)
            if property and item and (item.flags() & Qt.ItemIsEnabled):
                editor = self.m_editorPrivate.createEditor(property, parent)
                if editor:
                    hash = editor.__hash__()
                    editor.setProperty('hash_value',hash)
                    editor.hash_value = hash
                    editor.setAutoFillBackground(True)
                    editor.installEventFilter(self)
                    editor.destroyed.connect(self.slotEditorDestroyed)
                    self.m_propertyToEditor[property] = editor
                    self.m_editorToProperty[editor] = property
                    self.m_editedItem = item
                    self.m_editedWidget = editor

                    return editor
        return

    def updateEditorGeometry(self, editor, option, index):
        editor.setGeometry(option.rect.adjusted(0, 0, 0, -1))

    def paint(self, painter, option, index):
        hasValue = True
        if (self.m_editorPrivate):
            property = self.m_editorPrivate.indexToProperty(index)
            if (property):
                hasValue = property.hasValue()

        opt = QStyleOptionViewItem(option)
        if ((self.m_editorPrivate and index.column() == 0) or not hasValue):
            property = self.m_editorPrivate.indexToProperty(index)
            if (property and property.isModified()):
#.........这里部分代码省略.........
开发者ID:theall,项目名称:QtPropertyBrowserV2.6-for-pyqt5,代码行数:103,代码来源:qttreepropertybrowser.py

示例9: QtGroupBoxPropertyBrowserPrivate

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]
class QtGroupBoxPropertyBrowserPrivate():
    def __init__(self):
        self.q_ptr = None
        self.m_indexToItem = QMap()
        self.m_itemToIndex = QMap()
        self.m_widgetToItem = QMap()
        self.m_mainLayout = 0
        self.m_children = QList()
        self.m_recreateQueue = QList()

    def createEditor(self, property, parent):
        return self.q_ptr.createEditor(property, parent)

    def init(self, parent):
        self.m_mainLayout = QGridLayout()
        parent.setLayout(self.m_mainLayout)
        item = QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding)
        self.m_mainLayout.addItem(item, 0, 0)

    def slotEditorDestroyed(self):
        editor = self.q_ptr.sender()
        if (not editor):
            return
        if (not editor in self.m_widgetToItem.keys()):
            return
        self.m_widgetToItem[editor].widget = 0
        self.m_widgetToItem.remove(editor)

    def slotUpdate(self):
        for item in self.m_recreateQueue:
            par = item.parent
            w = 0
            l = 0
            oldRow = -1
            if (not par):
                w = self.q_ptr
                l = self.m_mainLayout
                oldRow = self.m_children.indexOf(item)
            else:
                w = par.groupBox
                l = par.layout
                oldRow = par.children.indexOf(item)
                if (self.hasHeader(par)):
                    oldRow += 2

            if (item.widget):
                item.widget.setParent(w)
            elif (item.widgetLabel):
                item.widgetLabel.setParent(w)
            else:
                item.widgetLabel = QLabel(w)
                item.widgetLabel.setSizePolicy(QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed))
                item.widgetLabel.setTextFormat(Qt.PlainText)

            span = 1
            if (item.widget):
                l.addWidget(item.widget, oldRow, 1, 1, 1)
            elif (item.widgetLabel):
                l.addWidget(item.widgetLabel, oldRow, 1, 1, 1)
            else:
                span = 2
            item.label = QLabel(w)
            item.label.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
            l.addWidget(item.label, oldRow, 0, 1, span)

            self.updateItem(item)

        self.m_recreateQueue.clear()

    def updateLater(self):
        QTimer.singleShot(0, self.q_ptr, self.slotUpdate())

    def propertyInserted(self, index, afterIndex):
        afterItem = self.m_indexToItem[afterIndex]
        parentItem = self.m_indexToItem.value(index.parent())

        newItem = WidgetItem()
        newItem.parent = parentItem

        layout = 0
        parentWidget = 0
        row = -1
        if (not afterItem):
            row = 0
            if (parentItem):
                parentItem.children.insert(0, newItem)
            else:
                self.m_children.insert(0, newItem)
        else:
            if (parentItem):
                row = parentItem.children.indexOf(afterItem) + 1
                parentItem.children.insert(row, newItem)
            else:
                row = self.m_children.indexOf(afterItem) + 1
                self.m_children.insert(row, newItem)

        if (parentItem and self.hasHeader(parentItem)):
            row += 2

        if (not parentItem):
#.........这里部分代码省略.........
开发者ID:theall,项目名称:Python-Tiled,代码行数:103,代码来源:qtgroupboxpropertybrowser.py

示例10: TilesetManager

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]

#.........这里部分代码省略.........
            ##
            # Searches for a tileset matching the given specification.
            # @return a tileset matching the given specification, or 0 if none exists
            ##
            spec = arg
            for tileset in self.tilesets():
                if (tileset.imageSource() == spec.imageSource
                    and tileset.tileWidth() == spec.tileWidth
                    and tileset.tileHeight() == spec.tileHeight
                    and tileset.tileSpacing() == spec.tileSpacing
                    and tileset.margin() == spec.margin):

                    return tileset

            return None

    ##
    # Adds a tileset reference. This will make sure the tileset is watched for
    # changes and can be found using findTileset().
    ##
    def addReference(self, tileset):
        if (self.mTilesets.contains(tileset)):
            self.mTilesets[tileset] += 1
        else:
            self.mTilesets.insert(tileset, 1)
            imgSrc = tileset.imageSource()
            if (imgSrc != ''):
                self.mWatcher.addPath(imgSrc)

    ##
    # Removes a tileset reference. When the last reference has been removed,
    # the tileset is no longer watched for changes.
    ##
    def removeReference(self, tileset):
        if self.mTilesets[tileset]:
            self.mTilesets[tileset] -= 1
        if (self.mTilesets[tileset] == 0):
            self.mTilesets.remove(tileset)
            if (tileset.imageSource()!=''):
                self.mWatcher.removePath(tileset.imageSource())

    ##
    # Convenience method to add references to multiple tilesets.
    # @see addReference
    ##
    def addReferences(self, tilesets):
        for tileset in tilesets:
            self.addReference(tileset)

    ##
    # Convenience method to remove references from multiple tilesets.
    # @see removeReference
    ##
    def removeReferences(self, tilesets):
        for tileset in tilesets:
            self.removeReference(tileset)

    ##
    # Returns all currently available tilesets.
    ##
    def tilesets(self):
        return self.mTilesets.keys()

    ##
    # Forces a tileset to reload.
    ##
开发者ID:theall,项目名称:Python-Tiled,代码行数:70,代码来源:tilesetmanager.py

示例11: VariantManager

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]
class VariantManager(QtVariantPropertyManager):
    class Data:
        value = QVariant()
        x = 0
        y = 0

    def __init__(self, parent=None):
        super(VariantManager, self).__init__(parent)
        self.propertyToData = QMap()
        self.xToProperty = QMap()
        self.yToProperty = QMap()

        self.valueChangedSignal.connect(self.slotValueChanged)
        self.propertyDestroyedSignal.connect(self.slotPropertyDestroyed)

    def __del__(self):
        pass

    def slotValueChanged(self, property, value):
        if (self.xToProperty.contains(property)):
            pointProperty = self.xToProperty[property]
            v = self.value(pointProperty)
            p = v.value()
            p.setX(value)
            self.setValue(pointProperty, p)
        elif (self.yToProperty.contains(property)):
            pointProperty = self.yToProperty[property]
            v = self.value(pointProperty)
            p = v.value()
            p.setY(value)
            self.setValue(pointProperty, p)

    def slotPropertyDestroyed(self, property):
        if (self.xToProperty.contains(property)):
            pointProperty = self.xToProperty[property]
            self.propertyToData[pointProperty].x = 0
            self.xToProperty.remove(property)
        elif (self.yToProperty.contains(property)):
            pointProperty = self.yToProperty[property]
            self.propertyToData[pointProperty].y = 0
            self.yToProperty.remove(property)

    def isPropertyTypeSupported(self, propertyType):
        if (propertyType == QVariant.PointF):
            return True
        return super(VariantManager, self).isPropertyTypeSupported(propertyType)

    def valueType(self, propertyType):
        if (propertyType == QVariant.PointF):
            return QVariant.PointF
        return super(VariantManager, self).valueType(propertyType)

    def value(self, property):
        if (self.propertyToData.contains(property)):
            return self.propertyToData[property].value
        return super(VariantManager, self).value(property)

    def valueText(self, property):
        if (self.propertyToData.contains(property)):
            v = self.propertyToData[property].value
            p = v.value()
            return self.tr("(%.2f, %.2f)"%(p.x(), p.y()))

        return super(VariantManager, self).valueText(property)

    def setValue(self, property, val):
        if (self.propertyToData.contains(property)):
            if type(val)!=QVariant:
                val = QVariant(val)
            if (val.type() != QVariant.PointF and not val.canConvert(QVariant.PointF)):
                return
            p = val.value()
            d = self.propertyToData[property]
            d.value = QVariant(p)
            if (d.x):
                d.x.setValue(p.x())
            if (d.y):
                d.y.setValue(p.y())
            self.propertyToData[property] = d
            self.propertyChangedSignal.emit(property)
            self.valueChangedSignal.emit(property, p)
            return

        super(VariantManager, self).setValue(property, val)

    def initializeProperty(self, property):
        if (self.propertyType(property) == QVariant.PointF):
            d = VariantManager.Data()

            d.value = QVariant(QPointF(0, 0))

            d.x = self.addProperty(QVariant.Double)
            d.x.setPropertyName(self.tr("Position X"))
            property.addSubProperty(d.x)
            self.xToProperty[d.x] = property

            d.y = self.addProperty(QVariant.Double)
            d.y.setPropertyName(self.tr("Position Y"))
            property.addSubProperty(d.y)
            self.yToProperty[d.y] = property
#.........这里部分代码省略.........
开发者ID:theall,项目名称:QtPropertyBrowserV2.6-for-pyqt5,代码行数:103,代码来源:extension.py

示例12: MapObjectModel

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]

#.........这里部分代码省略.........
        self.mObjectGroups.clear()
        self.mGroups.clear()
        self.mGroups.clear()
        self.mObjects.clear()
        self.mObjects.clear()
        if (self.mMapDocument):
            self.mMap = self.mMapDocument.map()
            self.mMapDocument.layerAdded.connect(self.layerAdded)
            self.mMapDocument.layerChanged.connect(self.layerChanged)
            self.mMapDocument.layerAboutToBeRemoved.connect(self.layerAboutToBeRemoved)
            for og in self.mMap.objectGroups():
                if GROUPS_IN_DISPLAY_ORDER:
                    self.mObjectGroups.prepend(og)
                else:
                    self.mObjectGroups.append(og)
                self.mGroups.insert(og, ObjectOrGroup(og))
                for o in og.objects():
                    self.mObjects.insert(o, ObjectOrGroup(o))

        self.endResetModel()

    def insertObject(self, og, index, o):
        if (index >= 0):
            _x = index
        else:
            _x = og.objectCount()
        row = _x
        self.beginInsertRows(self.index(og), row, row)
        og.insertObject(row, o)
        self.mObjects.insert(o, ObjectOrGroup(o))
        self.endInsertRows()
        self.objectsAdded.emit(QList([o]))

    def removeObject(self, og, o):
        objects = QList()
        objects.append(o)
        row = og.objects().indexOf(o)
        self.beginRemoveRows(self.index(og), row, row)
        og.removeObjectAt(row)
        self.mObjects.remove(o)
        self.endRemoveRows()
        self.objectsRemoved.emit(objects)
        return row

    def moveObjects(self, og, _from, to, count):
        parent = self.index(og)
        if (not self.beginMoveRows(parent, _from, _from + count - 1, parent, to)):
            return

        og.moveObjects(_from, to, count)
        self.endMoveRows()

    # ObjectGroup color changed
    # FIXME: layerChanged should let the scene know that objects need redrawing
    def emitObjectsChanged(self, objects):
        if objects.isEmpty():
            return
        self.objectsChanged.emit(objects)

    def setObjectName(self, o, name):
        if o.name() == name:
            return
        o.setName(name)
        index = self.index(o)
        self.dataChanged.emit(index, index)
        self.objectsChanged.emit(QList([o]))
开发者ID:theall,项目名称:Python-Tiled,代码行数:70,代码来源:mapobjectmodel.py

示例13: TileStampManager

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]
class TileStampManager(QObject):
    setStamp = pyqtSignal(TileStamp)

    def __init__(self, toolManager, parent = None):
        super().__init__(parent)
        
        self.mStampsByName = QMap()
        self.mQuickStamps = QVector()
        for i in range(TileStampManager.quickStampKeys().__len__()):
            self.mQuickStamps.append(0)
        
        self.mTileStampModel = TileStampModel(self)
        self.mToolManager = toolManager

        prefs = preferences.Preferences.instance()
        prefs.stampsDirectoryChanged.connect(self.stampsDirectoryChanged)
        self.mTileStampModel.stampAdded.connect(self.stampAdded)
        self.mTileStampModel.stampRenamed.connect(self.stampRenamed)
        self.mTileStampModel.stampChanged.connect(self.saveStamp)
        self.mTileStampModel.stampRemoved.connect(self.deleteStamp)
        self.loadStamps()

    def __del__(self):
        # needs to be over here where the TileStamp type is complete
        pass
        
    ##
    # Returns the keys used for quickly accessible tile stamps.
    # Note: To store a tile layer <Ctrl> is added. The given keys will work
    # for recalling the stored values.
    ##
    def quickStampKeys():
        keys=[Qt.Key_1, Qt.Key_2, Qt.Key_3, Qt.Key_4, Qt.Key_5, Qt.Key_6, Qt.Key_7, Qt.Key_8, Qt.Key_9]
        return keys
        
    def tileStampModel(self):
        return self.mTileStampModel
        
    def createStamp(self):
        stamp = self.tampFromContext(self.mToolManager.selectedTool())
        if (not stamp.isEmpty()):
            self.mTileStampModel.addStamp(stamp)
        return stamp
    
    def addVariation(self, targetStamp):
        stamp = stampFromContext(self.mToolManager.selectedTool())
        if (stamp.isEmpty()):
            return
        if (stamp == targetStamp): # avoid easy mistake of adding duplicates
            return
        for variation in stamp.variations():
            self.mTileStampModel.addVariation(targetStamp, variation)

    def selectQuickStamp(self, index):
        stamp = self.mQuickStamps.at(index)
        if (not stamp.isEmpty()):
            self.setStamp.emit(stamp)
    
    def createQuickStamp(self, index):
        stamp = stampFromContext(self.mToolManager.selectedTool())
        if (stamp.isEmpty()):
            return
        self.setQuickStamp(index, stamp)
    
    def extendQuickStamp(self, index):
        quickStamp = self.mQuickStamps[index]
        if (quickStamp.isEmpty()):
            self.createQuickStamp(index)
        else:
            self.addVariation(quickStamp)
    
    def stampsDirectoryChanged(self):
        # erase current stamps
        self.mQuickStamps.fill(TileStamp())
        self.mStampsByName.clear()
        self.mTileStampModel.clear()
        self.loadStamps()

    def eraseQuickStamp(self, index):
        stamp = self.mQuickStamps.at(index)
        if (not stamp.isEmpty()):
            self.mQuickStamps[index] = TileStamp()
            if (not self.mQuickStamps.contains(stamp)):
                self.mTileStampModel.removeStamp(stamp)

    def setQuickStamp(self, index, stamp):
        stamp.setQuickStampIndex(index)
        # make sure existing quickstamp is removed from stamp model
        self.eraseQuickStamp(index)
        self.mTileStampModel.addStamp(stamp)
        self.mQuickStamps[index] = stamp
    
    def loadStamps(self):
        prefs = preferences.Preferences.instance()
        stampsDirectory = prefs.stampsDirectory()
        stampsDir = QDir(stampsDirectory)
        iterator = QDirIterator(stampsDirectory,
                              ["*.stamp"],
                              QDir.Files | QDir.Readable)
        while (iterator.hasNext()):
#.........这里部分代码省略.........
开发者ID:theall,项目名称:Python-Tiled,代码行数:103,代码来源:tilestampmanager.py

示例14: EditPolygonTool

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import remove [as 别名]

#.........这里部分代码省略.........
            self.mMousePressed = True
            self.mStart = event.scenePos()
            self.mScreenStart = event.screenPos()
            items = self.mapScene().items(self.mStart,
                                                                   Qt.IntersectsItemShape,
                                                                   Qt.DescendingOrder,
                                                                   viewTransform(event))
            self.mClickedObjectItem = first(items, MapObjectItem)
            self.mClickedHandle = first(items, PointHandle)
        elif x==Qt.RightButton:
            items = self.mapScene().items(event.scenePos(),
                                                                   Qt.IntersectsItemShape,
                                                                   Qt.DescendingOrder,
                                                                   viewTransform(event))
            clickedHandle = first(items)
            if (clickedHandle or not self.mSelectedHandles.isEmpty()):
                self.showHandleContextMenu(clickedHandle,
                                      event.screenPos())
            else:
                super().mousePressed(event)
        else:
            super().mousePressed(event)

    def mouseReleased(self, event):
        if (event.button() != Qt.LeftButton):
            return
        x = self.mMode
        if x==EditPolygonTool.NoMode:
            if (self.mClickedHandle):
                selection = self.mSelectedHandles
                modifiers = event.modifiers()
                if (modifiers & (Qt.ShiftModifier | Qt.ControlModifier)):
                    if (selection.contains(self.mClickedHandle)):
                        selection.remove(self.mClickedHandle)
                    else:
                        selection.insert(self.mClickedHandle)
                else:
                    selection.clear()
                    selection.insert(self.mClickedHandle)

                self.setSelectedHandles(selection)
            elif (self.mClickedObjectItem):
                selection = self.mapScene().selectedObjectItems()
                modifiers = event.modifiers()
                if (modifiers & (Qt.ShiftModifier | Qt.ControlModifier)):
                    if (selection.contains(self.mClickedObjectItem)):
                        selection.remove(self.mClickedObjectItem)
                    else:
                        selection.insert(self.mClickedObjectItem)
                else:
                    selection.clear()
                    selection.insert(self.mClickedObjectItem)

                self.mapScene().setSelectedObjectItems(selection)
                self.updateHandles()
            elif (not self.mSelectedHandles.isEmpty()):
                # First clear the handle selection
                self.setSelectedHandles(QSet())
            else:
                # If there is no handle selection, clear the object selection
                self.mapScene().setSelectedObjectItems(QSet())
                self.updateHandles()
        elif x==EditPolygonTool.Selecting:
            self.updateSelection(event)
            self.mapScene().removeItem(self.mSelectionRectangle)
            self.mMode = EditPolygonTool.NoMode
开发者ID:theall,项目名称:Python-Tiled,代码行数:70,代码来源:editpolygontool.py


注:本文中的pyqtcore.QMap.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。