本文整理汇总了Python中pyqtcore.QVector.fill方法的典型用法代码示例。如果您正苦于以下问题:Python QVector.fill方法的具体用法?Python QVector.fill怎么用?Python QVector.fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtcore.QVector
的用法示例。
在下文中一共展示了QVector.fill方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TileStampManager
# 需要导入模块: from pyqtcore import QVector [as 别名]
# 或者: from pyqtcore.QVector import fill [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()):
#.........这里部分代码省略.........