本文整理汇总了Python中pyqtcore.QList.removeAt方法的典型用法代码示例。如果您正苦于以下问题:Python QList.removeAt方法的具体用法?Python QList.removeAt怎么用?Python QList.removeAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtcore.QList
的用法示例。
在下文中一共展示了QList.removeAt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QtButtonPropertyBrowserPrivate
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import removeAt [as 别名]
#.........这里部分代码省略.........
if (newItem.widget):
newItem.widget.destroyed.connect(self.slotEditorDestroyed)
self.m_widgetToItem[newItem.widget] = newItem
elif (index.property().hasValue()):
newItem.widgetLabel = QLabel(parentWidget)
newItem.widgetLabel.setSizePolicy(QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed))
self.insertRow(layout, row)
span = 1
if (newItem.widget):
layout.addWidget(newItem.widget, row, 1)
elif (newItem.widgetLabel):
layout.addWidget(newItem.widgetLabel, row, 1)
else:
span = 2
layout.addWidget(newItem.label, row, 0, span, 1)
self.m_itemToIndex[newItem] = index
self.m_indexToItem[index] = newItem
self.updateItem(newItem)
def propertyRemoved(self, index):
item = self.m_indexToItem[index]
self.m_indexToItem.remove(index)
self.m_itemToIndex.remove(item)
parentItem = item.parent
row = self.gridRow(item)
if (parentItem):
parentItem.children.removeAt(parentItem.children.indexOf(item))
else:
self.m_children.removeAt(self.m_children.indexOf(item))
colSpan = self.gridSpan(item)
self.m_buttonToItem.remove(item.button)
if (item.widget):
item.widget.close()
del item.widget
if (item.label):
item.label.close()
del item.label
if (item.widgetLabel):
item.widgetLabel.close()
del item.widgetLabel
if (item.button):
item.button.close()
del item.button
if (item.container):
item.container.close()
del item.container
if (not parentItem):
self.removeRow(self.m_mainLayout, row)
if (colSpan > 1):
self.removeRow(self.m_mainLayout, row)
elif (len(parentItem.children) != 0):
self.removeRow(parentItem.layout, row)
if (colSpan > 1):
self.removeRow(parentItem.layout, row)
else:
示例2: QtGroupBoxPropertyBrowserPrivate
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import removeAt [as 别名]
#.........这里部分代码省略.........
newItem.widgetLabel.setSizePolicy(QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed))
newItem.widgetLabel.setTextFormat(Qt.PlainText)
else:
newItem.widget.destroyed.connect(self.slotEditorDestroyed)
self.m_widgetToItem[newItem.widget] = newItem
self.insertRow(layout, row)
span = 1
if (newItem.widget):
layout.addWidget(newItem.widget, row, 1)
elif (newItem.widgetLabel):
layout.addWidget(newItem.widgetLabel, row, 1)
else:
span = 2
layout.addWidget(newItem.label, row, 0, 1, span)
self.m_itemToIndex[newItem] = index
self.m_indexToItem[index] = newItem
self.updateItem(newItem)
def propertyRemoved(self, index):
item = self.m_indexToItem[index]
self.m_indexToItem.remove(index)
self.m_itemToIndex.remove(item)
parentItem = item.parent
row = -1
if (parentItem):
row = parentItem.children.indexOf(item)
parentItem.children.removeAt(row)
if (self.hasHeader(parentItem)):
row += 2
else:
row = self.m_children.indexOf(item)
self.m_children.removeAt(row)
if (item.widget):
item.widget.close()
del item.widget
if (item.label):
item.label.close()
del item.label
if (item.widgetLabel):
item.widgetLabel.close()
del item.widgetLabel
if (item.groupBox):
item.groupBox.close()
del item.groupBox
if (not parentItem):
self.removeRow(self.m_mainLayout, row)
elif len(parentItem.children) > 0:
self.removeRow(parentItem.layout, row)
else:
par = parentItem.parent
l = 0
oldRow = -1
if (not par):
l = self.m_mainLayout
oldRow = self.m_children.indexOf(parentItem)
else:
l = par.layout
示例3: CommandDataModel
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import removeAt [as 别名]
#.........这里部分代码省略.........
##
def allCommands(self):
return QList(self.mCommands)
##
# Remove the given row or rows from the model.
##
def removeRows(self, *args):
l = len(args)
if l>1 and l<4:
row = args[0]
count = args[1]
if l==2:
parent = QModelIndex()
elif l==3:
parent = args[2]
if (row < 0 or row + count > self.mCommands.size()):
return False
self.beginRemoveRows(parent, row, row + count)
self.mCommands.erase(self.mCommands.begin() + row, self.mCommands.begin() + row + count)
self.endRemoveRows()
return True
elif l==1:
indices = args[0]
##
# Deletes the commands associated with the given row <i>indices</i>.
##
while (not indices.empty()):
row = indices.takeFirst().row()
if (row >= self.mCommands.size()):
continue
self.beginRemoveRows(QModelIndex(), row, row)
self.mCommands.removeAt(row)
# Decrement later indices since we removed a row
for i in indices:
if (i.row() > row):
i = i.sibling(i.row() - 1, i.column())
self.endRemoveRows()
##
# Returns the number of rows (this includes the <New Command> row).
##
def rowCount(self, parent):
if parent.isValid():
return 0
else:
return self.mCommands.size() + 1
##
# Returns the number of columns.
##
def columnCount(self, parent):
if parent.isValid():
return 0
else:
return 3
##
# Returns the data at <i>index</i> for the given <i>role</i>.
##
def data(self, index, role = Qt.DisplayRole):
isNormalRow = index.row() < self.mCommands.size()
command = Command()
if (isNormalRow):
command = self.mCommands[index.row()]
示例4: Map
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import removeAt [as 别名]
#.........这里部分代码省略.........
##
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)
##
# Removes the tileset at \a index from this map.
#
# \warning Does not make sure that this map no longer refers to tiles from
# the removed tileset!
#
# \sa addTileset
##
def removeTilesetAt(self, index):
self.mTilesets.removeAt(index)
##
# Replaces all tiles from \a oldTileset with tiles from \a newTileset.
# Also replaces the old tileset with the new tileset in the list of
# tilesets.
##
def replaceTileset(self, oldTileset, newTileset):
index = self.mTilesets.indexOf(oldTileset)
for layer in self.mLayers:
layer.replaceReferencesToTileset(oldTileset, newTileset)
self.mTilesets[index] = newTileset
##
# Returns the number of tilesets of this map.
##
def tilesetCount(self):
return self.mTilesets.size()
##
# Returns the tileset at the given index.
##
def tilesetAt(self, index):
return self.mTilesets.at(index)
##
# Returns the tilesets that the tiles on this map are using.
##
def tilesets(self):
return QList(self.mTilesets)
##
# Returns the background color of this map.
示例5: ObjectGroup
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import removeAt [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)
#.........这里部分代码省略.........
示例6: MapObjectModel
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import removeAt [as 别名]
#.........这里部分代码省略.........
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]))
def setObjectType(self, o, type):
if o.type() == type:
return
o.setType(type)
index = self.index(o, 1)
self.dataChanged.emit(index, index)
self.objectsChanged.emit(QList([o]))
def setObjectPolygon(self, o, polygon):
if o.polygon() == polygon:
return
o.setPolygon(polygon)
self.objectsChanged.emit(QList([o]))
def setObjectPosition(self, o, pos):
if o.position() == pos:
return
o.setPosition(pos)
self.objectsChanged.emit(QList([o]))
def setObjectSize(self, o, size):
if o.size() == size:
return
o.setSize(size)
self.objectsChanged.emit(QList([o]))
def setObjectRotation(self, o, rotation):
if o.rotation() == rotation:
return
o.setRotation(rotation)
self.objectsChanged.emit(QList([o]))
def setObjectVisible(self, o, visible):
if o.isVisible() == visible:
return
o.setVisible(visible)
index = self.index(o)
self.dataChanged.emit(index, index)
self.objectsChanged.emit(QList([o]))
def layerAdded(self, index):
layer = self.mMap.layerAt(index)
og = layer.asObjectGroup()
if og:
if (not self.mGroups.contains(og)):
prev = None
for index in range(index - 1, -1, -1):
prev = self.mMap.layerAt(index).asObjectGroup()
if prev:
break
if GROUPS_IN_DISPLAY_ORDER:
if prev:
_x = self.mObjectGroups.indexOf(prev)
else:
_x = self.mObjectGroups.count()
index = _x
else:
if prev:
index = self.mObjectGroups.indexOf(prev) + 1
else:
index = 0
self.mObjectGroups.insert(index, og)
row = self.mObjectGroups.indexOf(og)
self.beginInsertRows(QModelIndex(), row, row)
self.mGroups.insert(og, ObjectOrGroup(og))
for o in og.objects():
if (not self.mObjects.contains(o)):
self.mObjects.insert(o, ObjectOrGroup(o))
self.endInsertRows()
def layerChanged(self, index):
layer = self.mMap.layerAt(index)
og = layer.asObjectGroup()
if og:
index = self.index(og)
self.dataChanged.emit(index, index)
def layerAboutToBeRemoved(self, index):
layer = self.mMap.layerAt(index)
og = layer.asObjectGroup()
if og:
row = self.mObjectGroups.indexOf(og)
self.beginRemoveRows(QModelIndex(), row, row)
self.mObjectGroups.removeAt(row)
self.mGroups.remove(og)
for o in og.objects():
self.mObjects.remove(og)
self.endRemoveRows()
示例7: TileStampModel
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import removeAt [as 别名]
#.........这里部分代码省略.........
x = role
if x==Qt.DisplayRole or x==Qt.EditRole:
return variation.probability
return QVariant()
def flags(self, index):
rc = QAbstractItemModel.flags(index)
validParent = index.parent().isValid()
if ((not validParent and index.column() == 0) or # can edit stamp names
(validParent and index.column() == 1)): # and variation probability
rc |= Qt.ItemIsEditable
return rc
def removeRows(self, row, count, parent):
if (parent.isValid()):
# removing variations
stamp = self.mStamps[parent.row()]
# if only one variation is left, we make all variation rows disappear
if (stamp.variations().size() - count == 1):
self.beginRemoveRows(parent, 0, count)
else:
self.beginRemoveRows(parent, row, row + count - 1)
for x in range(count, 0, -1):
self.mThumbnailCache.remove(stamp.variations().at(row).map)
stamp.deleteVariation(row)
self.endRemoveRows()
if (stamp.variations().isEmpty()):
# remove stamp since all its variations were removed
self.beginRemoveRows(QModelIndex(), parent.row(), parent.row())
self.stampRemoved.emit(stamp)
self.mStamps.removeAt(parent.row())
self.endRemoveRows()
else :
if (row == 0):
# preview on stamp and probability sum need update
# (while technically I think this is correct, it triggers a
# repainting issue in QTreeView)
#emit dataChanged(index(parent.row(), 0),
# self.index(parent.row(), 1))
pass
self.stampChanged.emit(stamp)
else :
# removing stamps
self.beginRemoveRows(parent, row, row + count - 1)
for x in range(count, 0, -1):
for variation in self.mStamps.at(row).variations():
self.mThumbnailCache.remove(variation.map)
self.stampRemoved.emit(self.mStamps.at(row))
self.mStamps.removeAt(row)
self.endRemoveRows()
return True
##
# Returns the stamp at the given \a index.
##
def stampAt(self, index):
return self.mStamps.at(index.row())
def isStamp(self, index):
return index.isValid() \
示例8: DocumentManager
# 需要导入模块: from pyqtcore import QList [as 别名]
# 或者: from pyqtcore.QList import removeAt [as 别名]
#.........这里部分代码省略.........
view = MapView()
scene = MapScene(view) # scene is owned by the view
container = MapViewContainer(view, self.mTabWidget)
scene.setMapDocument(mapDocument)
view.setScene(scene)
documentIndex = self.mDocuments.size() - 1
self.mTabWidget.addTab(container, mapDocument.displayName())
self.mTabWidget.setTabToolTip(documentIndex, mapDocument.fileName())
mapDocument.fileNameChanged.connect(self.fileNameChanged)
mapDocument.modifiedChanged.connect(self.updateDocumentTab)
mapDocument.saved.connect(self.documentSaved)
container.reload.connect(self.reloadRequested)
self.switchToDocument(documentIndex)
self.centerViewOn(0, 0)
##
# Closes the current map document. Will not ask the user whether to save
# any changes!
##
def closeCurrentDocument(self):
index = self.mTabWidget.currentIndex()
if (index == -1):
return
self.closeDocumentAt(index)
##
# Closes the document at the given \a index. Will not ask the user whether
# to save any changes!
##
def closeDocumentAt(self, index):
mapDocument = self.mDocuments.at(index)
self.documentAboutToClose.emit(mapDocument)
self.mDocuments.removeAt(index)
self.mTabWidget.removeTab(index)
if (mapDocument.fileName() != ''):
self.mFileSystemWatcher.removePath(mapDocument.fileName())
self.mUndoGroup.removeStack(mapDocument.undoStack())
##
# Reloads the current document. Will not ask the user whether to save any
# changes!
#
# \sa reloadDocumentAt()
##
def reloadCurrentDocument(self):
index = self.mTabWidget.currentIndex()
if (index == -1):
return False
return self.reloadDocumentAt(index)
##
# Reloads the document at the given \a index. It will lose any undo
# history and current selections. Will not ask the user whether to save
# any changes!
#
# Returns whether the map loaded successfully.
##
def reloadDocumentAt(self, index):
oldDocument = self.mDocuments.at(index)
newDocument, error = MapDocument.load(oldDocument.fileName(), oldDocument.readerFormat())
if (not newDocument):
self.reloadError.emit(self.tr("%s:\n\n%s"%(oldDocument.fileName(), error)))