本文整理汇总了Python中pyqtcore.QMap.value方法的典型用法代码示例。如果您正苦于以下问题:Python QMap.value方法的具体用法?Python QMap.value怎么用?Python QMap.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtcore.QMap
的用法示例。
在下文中一共展示了QMap.value方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FormatHelper
# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import value [as 别名]
class FormatHelper():
def __init__(self, capabilities, initialFilter):
self.mFilter = initialFilter
self.mFormats = QList()
self.mFormatByNameFilter = QMap()
def t(self, format):
if (format.hasCapabilities(capabilities)):
nameFilter = format.nameFilter()
self.mFilter += ";;"
self.mFilter += nameFilter
self.mFormats.append(format)
self.mFormatByNameFilter.insert(nameFilter, format)
PluginManager.each(self, t)
def filter(self):
return self.mFilter
def formats(self):
return self.mFormats
def formatByNameFilter(self, nameFilter):
return self.mFormatByNameFilter.value(nameFilter)
示例2: QtButtonPropertyBrowserPrivate
# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import value [as 别名]
#.........这里部分代码省略.........
if (expanded):
self.insertRow(l, row + 1)
l.addWidget(item.container, row + 1, 0, 1, 2)
item.container.show()
else:
l.removeWidget(item.container)
item.container.hide()
self.removeRow(l, row + 1)
item.button.setChecked(expanded)
if expanded:
item.button.setArrowType(Qt.UpArrow)
else:
item.button.setArrowType(Qt.DownArrow)
def slotToggled(self, checked):
item = self.m_buttonToItem[self.q_ptr.sender()]
if (not item):
return
self.setExpanded(item, checked)
if (checked):
self.q_ptr.expandedSignal.emit(self.m_itemToIndex[item])
else:
self.q_ptr.collapsedSignal.emit(self.m_itemToIndex[item])
def updateLater(self):
QTimer.singleShot(0, 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:
row = self.gridRow(afterItem) + self.gridSpan(afterItem)
if (parentItem):
parentItem.children.insert(parentItem.children.indexOf(afterItem) + 1, newItem)
else:
self.m_children.insert(self.m_children.indexOf(afterItem) + 1, newItem)
if (not parentItem):
layout = self.m_mainLayout
parentWidget = self.q_ptr
else:
if (not parentItem.container):
self.m_recreateQueue.removeAll(parentItem)
grandParent = parentItem.parent
l = 0
oldRow = self.gridRow(parentItem)
if (grandParent):
l = grandParent.layout
else:
示例3: QtGroupBoxPropertyBrowserPrivate
# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import value [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):
#.........这里部分代码省略.........
示例4: ObjectControllerPrivate
# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import value [as 别名]
class ObjectControllerPrivate():
def __init__(self):
self.q_ptr = 0
self.m_object = 0
self.m_classToProperty = QMap()
self.m_propertyToClass = QMap()
self.m_propertyToIndex = QMap()
self.m_classToIndexToProperty = QMapMap()
self.m_propertyToExpanded = QMap()
self.m_topLevelProperties = QList()
self.m_browser = 0
self.m_manager = 0
self.m_readOnlyManager = 0
def enumToInt(self, metaEnum, enumValue):
valueMap = QMap() # dont show multiple enum values which have the same values
pos = 0
for i in range(metaEnum.keyCount()):
value = metaEnum.value(i)
if (not valueMap.contains(value)):
if (value == enumValue):
return pos
valueMap[value] = pos
pos += 1
return -1
def intToEnum(self, metaEnum, intValue):
valueMap = QMap() # dont show multiple enum values which have the same values
values = QList()
for i in range(metaEnum.keyCount()):
value = metaEnum.value(i)
if (not valueMap.contains(value)):
valueMap[value] = True
values.append(value)
if (intValue >= values.count()):
return -1
return values.at(intValue)
def isSubValue(self, value, subValue):
if (value == subValue):
return True
i = 0
while (subValue):
if (not (value & (1 << i))):
if (subValue & 1):
return False
i += 1
subValue = subValue >> 1
return True
def isPowerOf2(self, value):
while (value):
if (value & 1):
return value == 1
value = value >> 1
return False
def flagToInt(self, metaEnum, flagValue):
if (not flagValue):
return 0
intValue = 0
valueMap = QMap() # dont show multiple enum values which have the same values
pos = 0
for i in range(metaEnum.keyCount()):
value = metaEnum.value(i)
if (not valueMap.contains(value) and self.isPowerOf2(value)):
if (self.isSubValue(flagValue, value)):
intValue |= (1 << pos)
valueMap[value] = pos
pos += 1
return intValue
def intToFlag(self, metaEnum, intValue):
valueMap = QMap() # dont show multiple enum values which have the same values
values = QList()
for i in range(metaEnum.keyCount()):
value = metaEnum.value(i)
if (not valueMap.contains(value) and self.isPowerOf2(value)):
valueMap[value] = True
values.append(value)
flagValue = 0
temp = intValue
i = 0
while (temp):
if (i >= values.count()):
return -1
if (temp & 1):
flagValue |= values.at(i)
i += 1
temp = temp >> 1
return flagValue
#.........这里部分代码省略.........
示例5: GidMapper
# 需要导入模块: from pyqtcore import QMap [as 别名]
# 或者: from pyqtcore.QMap import value [as 别名]
class GidMapper():
##
# Default constructor. Use \l insert to initialize the gid mapper
# incrementally.
##
def __init__(self, *args):
self.mInvalidTile = None
self.mTilesetColumnCounts = QMap()
self.mFirstGidToTileset = QMap()
if len(args)==1:
##
# Constructor that initializes the gid mapper using the given \a tilesets.
##
firstGid = 1
tilesets = args[0]
for tileset in tilesets:
self.insert(firstGid, tileset)
firstGid += tileset.tileCount()
##
# Insert the given \a tileset with \a firstGid as its first global ID.
##
def insert(self, firstGid, tileset):
self.mFirstGidToTileset.insert(firstGid, tileset)
##
# Clears the gid mapper, so that it can be reused.
##
def clear(self):
self.mFirstGidToTileset.clear()
##
# Returns True when no tilesets are known to this gid mapper.
##
def isEmpty(self):
return self.mFirstGidToTileset.isEmpty()
##
# Returns the GID of the invalid tile in case decodeLayerData() returns
# the InvalidTile error.
##
def invalidTile(self):
return self.mInvalidTile
##
# Returns the cell data matched by the given \a gid. The \a ok parameter
# indicates whether an error occurred.
##
def gidToCell(self, gid):
result = Cell()
# Read out the flags
result.flippedHorizontally = (gid & FlippedHorizontallyFlag)
result.flippedVertically = (gid & FlippedVerticallyFlag)
result.flippedAntiDiagonally = (gid & FlippedAntiDiagonallyFlag)
# Clear the flags
gid &= ~(FlippedHorizontallyFlag |
FlippedVerticallyFlag |
FlippedAntiDiagonallyFlag)
if (gid == 0):
ok = True
elif (self.isEmpty()):
ok = False
else:
# Find the tileset containing this tile
index = self.mFirstGidToTileset.upperBound(gid)
if index==0:
ok = False
else:
item = self.mFirstGidToTileset.itemByIndex(index-1)
# Navigate one tileset back since upper bound finds the next
tileId = gid - item[0]
tileset = item[1]
columnCount = self.mTilesetColumnCounts.value(tileset, 0)
if (columnCount > 0 and columnCount != tileset.columnCount()):
# Correct tile index for changes in image width
row = int(tileId / columnCount)
column = int(tileId % columnCount)
tileId = row * tileset.columnCount() + column
result.tile = tileset.tileAt(tileId)
ok = True
return result, ok
##
# Returns the global tile ID for the given \a cell. Returns 0 when the
# cell is empty or when its tileset isn't known.
##
def cellToGid(self, cell):
if (cell.isEmpty()):
return 0
tileset = cell.tile.tileset()
# Find the first GID for the tileset
for item in self.mFirstGidToTileset:
if item[1] == tileset:
gid = item[0] + cell.tile.id()
if (cell.flippedHorizontally):
gid |= FlippedHorizontallyFlag
if (cell.flippedVertically):
gid |= FlippedVerticallyFlag
#.........这里部分代码省略.........