本文整理汇总了Python中pyqtcore.QList.takeAt方法的典型用法代码示例。如果您正苦于以下问题:Python QList.takeAt方法的具体用法?Python QList.takeAt怎么用?Python QList.takeAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtcore.QList
的用法示例。
在下文中一共展示了QList.takeAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Map
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import takeAt [as 别名]
#.........这里部分代码省略.........
##
# Adds a layer to this map.
##
def addLayer(self, layer):
self.adoptLayer(layer)
self.mLayers.append(layer)
##
# Returns the index of the layer given by \a layerName, or -1 if no
# layer with that name is found.
#
# The second optional parameter specifies the layer types which are
# searched.
##
def indexOfLayer(self, layerName, layertypes = Layer.AnyLayerType):
for index in range(self.mLayers.size()):
if (self.layerAt(index).name() == layerName and (layertypes & self.layerAt(index).layerType())):
return index
return -1
##
# Adds a layer to this map, inserting it at the given index.
##
def insertLayer(self, index, layer):
self.adoptLayer(layer)
self.mLayers.insert(index, layer)
##
# Removes the layer at the given index from this map and returns it.
# The caller becomes responsible for the lifetime of this layer.
##
def takeLayerAt(self, index):
layer = self.mLayers.takeAt(index)
layer.setMap(None)
return layer
##
# Adds a tileset to this map. The map does not take ownership over its
# tilesets, this is merely for keeping track of which tilesets are used by
# the map, and their saving order.
#
# @param tileset the tileset to add
##
def addTileset(self, tileset):
self.mTilesets.append(tileset)
##
# Convenience function to be used together with Layer.usedTilesets()
##
def addTilesets(self, tilesets):
for tileset in tilesets:
self.addTileset(tileset)
##
# Inserts \a tileset at \a index in the list of tilesets used by this map.
##
def insertTileset(self, index, tileset):
self.mTilesets.insert(index, tileset)
##
# Returns the index of the given \a tileset, or -1 if it is not used in
# this map.
##
def indexOfTileset(self, tileset):
return self.mTilesets.indexOf(tileset)
示例2: Tileset
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import takeAt [as 别名]
#.........这里部分代码省略.........
def addTerrain(self, name, imageTileId):
terrain = Terrain(self.terrainCount(), self, name, imageTileId)
self.insertTerrain(self.terrainCount(), terrain)
return terrain
##
# Adds the \a terrain type at the given \a index.
#
# The terrain should already have this tileset associated with it.
##
def insertTerrain(self, index, terrain):
self.mTerrainTypes.insert(index, terrain)
# Reassign terrain IDs
for terrainId in range(index, self.mTerrainTypes.size()):
self.mTerrainTypes.at(terrainId).mId = terrainId
# Adjust tile terrain references
for tile in self.mTiles:
for corner in range(4):
terrainId = tile.cornerTerrainId(corner)
if (terrainId >= index):
tile.setCornerTerrainId(corner, terrainId + 1)
self.mTerrainDistancesDirty = True
##
# Removes the terrain type at the given \a index and returns it. The
# caller becomes responsible for the lifetime of the terrain type.
#
# This will cause the terrain ids of subsequent terrains to shift up to
# fill the space and the terrain information of all tiles in this tileset
# will be updated accordingly.
##
def takeTerrainAt(self, index):
terrain = self.mTerrainTypes.takeAt(index)
# Reassign terrain IDs
for terrainId in range(index, self.mTerrainTypes.size()):
self.mTerrainTypes.at(terrainId).mId = terrainId
# Clear and adjust tile terrain references
for tile in self.mTiles:
for corner in range(4):
terrainId = tile.cornerTerrainId(corner)
if (terrainId == index):
tile.setCornerTerrainId(corner, 0xFF)
elif (terrainId > index):
tile.setCornerTerrainId(corner, terrainId - 1)
self.mTerrainDistancesDirty = True
return terrain
##
# Returns the transition penalty(/distance) between 2 terrains. -1 if no
# transition is possible.
##
def terrainTransitionPenalty(self, terrainType0, terrainType1):
if (self.mTerrainDistancesDirty):
self.recalculateTerrainDistances()
self.mTerrainDistancesDirty = False
if terrainType0 == 255:
terrainType0 = -1
if terrainType1 == 255:
terrainType1 = -1
# Do some magic, since we don't have a transition array for no-terrain
if (terrainType0 == -1 and terrainType1 == -1):
示例3: ObjectGroup
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import takeAt [as 别名]
class ObjectGroup(Layer):
##
# Objects within an object group can either be drawn top down (sorted
# by their y-coordinate) or by index (manual stacking order).
#
# The default is top down.
##
class DrawOrder():
UnknownOrder = -1
TopDownOrder = 1
IndexOrder = 2
##
# Default constructor.
##
def __init__(self, *args):
self.mObjects = QList()
self.mColor = QColor()
l = len(args)
if l==0:
super().__init__(Layer.ObjectGroupType, QString(), 0, 0, 0, 0)
elif l==5:
##
# Constructor with some parameters.
##
name, x, y, width, height = args
super().__init__(Layer.ObjectGroupType, name, x, y, width, height)
else:
pass
self.mDrawOrder = ObjectGroup.DrawOrder.IndexOrder
##
# Destructor.
##
def __del__(self):
self.mObjects.clear()
##
# Returns a pointer to the list of objects in this object group.
##
def objects(self):
return QList(self.mObjects)
##
# Returns the number of objects in this object group.
##
def objectCount(self):
return self.mObjects.size()
##
# Returns the object at the specified index.
##
def objectAt(self, index):
return self.mObjects.at(index)
##
# Adds an object to this object group.
##
def addObject(self, object):
self.mObjects.append(object)
object.setObjectGroup(self)
if (self.mMap and object.id() == 0):
object.setId(self.mMap.takeNextObjectId())
##
# Inserts an object at the specified index. This is only used for undoing
# the removal of an object at the moment, to make sure not to change the
# saved order of the objects.
##
def insertObject(self, index, object):
self.mObjects.insert(index, object)
object.setObjectGroup(self)
if (self.mMap and object.id() == 0):
object.setId(self.mMap.takeNextObjectId())
##
# Removes an object from this object group. Ownership of the object is
# transferred to the caller.
#
# @return the index at which the specified object was removed
##
def removeObject(self, object):
index = self.mObjects.indexOf(object)
self.mObjects.removeAt(index)
object.setObjectGroup(None)
return index
##
# Removes the object at the given index. Ownership of the object is
# transferred to the caller.
#
# This is faster than removeObject when you've already got the index.
#
# @param index the index at which to remove an object
##
def removeObjectAt(self, index):
object = self.mObjects.takeAt(index)
object.setObjectGroup(None)
#.........这里部分代码省略.........