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


Python QMap.constEnd方法代码示例

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


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

示例1: VariantEditorFactory

# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import constEnd [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


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