當前位置: 首頁>>代碼示例>>Python>>正文


Python QList.contains方法代碼示例

本文整理匯總了Python中pyqtcore.QList.contains方法的典型用法代碼示例。如果您正苦於以下問題:Python QList.contains方法的具體用法?Python QList.contains怎麽用?Python QList.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyqtcore.QList的用法示例。


在下文中一共展示了QList.contains方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TileStampModel

# 需要導入模塊: from pyqtcore import QList [as 別名]
# 或者: from pyqtcore.QList import contains [as 別名]

#.........這裏部分代碼省略.........
                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() \
                and not index.parent().isValid() \
                and index.row() < self.mStamps.size()
    
    def variationAt(self, index):
        if (not index.isValid()):
            return None
        parent = index.parent()
        if (self.isStamp(parent)):
            stamp = self.mStamps.at(parent.row())
            return stamp.variations().at(index.row())
        
        return None
        
    def stamps(self):
        return self.mStamps

    def addStamp(self, stamp):
        if (self.mStamps.contains(stamp)):
            return
        self.beginInsertRows(QModelIndex(), self.mStamps.size(), self.mStamps.size())
        self.mStamps.append(stamp)
        self.stampAdded.emit(stamp)
        self.endInsertRows()
    
    def removeStamp(self, stamp):
        index = self.mStamps.indexOf(stamp)
        if (index == -1):
            return
        self.beginRemoveRows(QModelIndex(), index, index)
        self.mStamps.removeAt(index)
        self.endRemoveRows()
        for variation in stamp.variations():
            self.mThumbnailCache.remove(variation.map)
        self.stampRemoved.emit(stamp)
    
    def addVariation(self, stamp, variation):
        index = self.mStamps.indexOf(stamp)
        if (index == -1):
            return
        variationCount = stamp.variations().size()
        if (variationCount == 1):
            self.beginInsertRows(TileStampModel.index(index, 0), 0, 1)
        else:
            self.beginInsertRows(TileStampModel.index(index, 0),
                            variationCount, variationCount)
        self.mStamps[index].addVariation(variation)
        self.endInsertRows()
        probabilitySumIndex = TileStampModel.index(index, 1)
        self.dataChanged.emit(probabilitySumIndex, probabilitySumIndex)
        self.stampChanged.emit(stamp)
    
    def clear(self):
        self.beginResetModel()
        self.mStamps.clear()
        self.mThumbnailCache.clear()
        self.endResetModel()
開發者ID:theall,項目名稱:Python-Tiled,代碼行數:104,代碼來源:tilestampmodel.py


注:本文中的pyqtcore.QList.contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。