当前位置: 首页>>代码示例>>Python>>正文


Python QtCore.QModelIndex方法代码示例

本文整理汇总了Python中PySide.QtCore.QModelIndex方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QModelIndex方法的具体用法?Python QtCore.QModelIndex怎么用?Python QtCore.QModelIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtCore的用法示例。


在下文中一共展示了QtCore.QModelIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_sub_signature

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def add_sub_signature(self, sub_sig_data, notes, index=None):
        element =  (sub_sig_data.get_save_data_tuple(), notes)
        if None == index:
            index = self.next_index
            self.next_index += 1

        pos = bisect.bisect(self.sub_signatures.keys(), index)
        if index not in self.sub_signatures:
            #   Add a new element
            self.beginInsertRows(QtCore.QModelIndex(), pos, pos)
            self.sub_signatures[index] = element
            sorted_data = sorted(self.sub_signatures.iteritems(), key=lambda x: x[0])
            self.sub_signatures = collections.OrderedDict(sorted_data)
            self.endInsertRows()

        else:
            #   Modify existing element
            self.sub_signatures[index] = element

        #   Add to IDB
        self.__set_array(element[0], notes, index)
        self.sub_signatures[index] = (element[0], notes)
        self.index_lookup_table.append(index) 
开发者ID:Cisco-Talos,项目名称:CASC,代码行数:25,代码来源:casc_plugin.py

示例2: flags

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def flags(self, index):
        '''
        Return the flags an index, if force flags is not set it will use
        the items own flags if it has them
        If index is None, it will return the model flags

        :param QModelIndex index: index to query
        :returns: flags
        :rtype: ItemFlags
        '''
        if index is None or self.__forceFlags:
            return self.__flags

        if not index.isValid():
            return self.__flags

        item = index.internalPointer()
        if item.hasCustomFlags:
            return item.flags()

        return self.__flags 
开发者ID:metalix00,项目名称:public,代码行数:23,代码来源:abstractModel.py

示例3: beginInsertion

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def beginInsertion(self, rows, position, parent):
        '''
        Internal utility to help inserting from multiple calls

        :param int rows: number of rows to add
        :param int position: position to start adding
        :param parent: parent to add to
        :type parent: QModelIndex or AbstractBaseMixin or None
        :returns: tuple(parentNode, position)
        :rtype: tuple
        '''
        if isinstance(parent, QtCore.QModelIndex):
            parentNode = self.getItem(parent)

        if parent is None:
            parent = QtCore.QModelIndex()
            parentNode = self.__root

        if position is None:
            position = parentNode.childCount()

        position = parentNode.childCount() if position is None else position

        self.beginInsertRows(parent, position, int(position) + rows - 1)
        return (parentNode, position) 
开发者ID:metalix00,项目名称:public,代码行数:27,代码来源:abstractModel.py

示例4: insertRows

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def insertRows(self, items, position=None, parent=None):
        '''
        Add new rows to the model

        :param list items: items to add
        :param int position: position to start adding
        :param parent: parent to add to
        :type parent: QModelIndex or AbstractBaseMixin or None
        :returns: Success
        :rtype: bool
        '''
        parentNode, position = self.beginInsertion(len(items), position, parent)
        success = True
        for item in items:
            success *= parentNode.insertChild(position, item)
            position += 1

        self.endInsertRows()
        return bool(success) 
开发者ID:metalix00,项目名称:public,代码行数:21,代码来源:abstractModel.py

示例5: removeRows

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def removeRows(self, position, rows, parent=None):
        '''
        Remove rows from the model

        :param int position: position to start adding
        :param int rows: number of rows to remove
        :param QModelIndex parent: parent to remove from
        :returns: Success
        :rtype: bool
        '''
        if parent is None:
            parent = QtCore.QModelIndex()

        parentNode = self.getItem(parent)
        self.beginRemoveRows(parent, position, position + rows - 1)

        for row in xrange(rows):
            success = parentNode.removeChild(position)

        self.endRemoveRows()

        return success 
开发者ID:metalix00,项目名称:public,代码行数:24,代码来源:abstractModel.py

示例6: rowCount

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def rowCount(self, index=QModelIndex()):
        return self.df.shape[0] 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:qtpandas.py

示例7: columnCount

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def columnCount(self, index=QModelIndex()):
        return self.df.shape[1] 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:qtpandas.py

示例8: __init__

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def __init__(self, parent=None, win=None, xrefs=None, headers=None):
        super(XrefValueWindow, self).__init__(parent)
        self.parent = parent
        self.mainwin = win
        self.xrefs = xrefs
        self.headers = headers

        self.reverse_strings = {}

        self.proxyModel = QtGui.QSortFilterProxyModel()
        self.proxyModel.setDynamicSortFilter(True)

        self.model = QtGui.QStandardItemModel(len(self.xrefs), len(self.headers), self)

        column = 0
        for header in headers:
            self.model.setHeaderData(column, QtCore.Qt.Horizontal, header)
            column += 1

        row = 0
        for ref in xrefs:
            for column in range(len(self.headers)):
                self.model.setData(self.model.index(row, column, QtCore.QModelIndex()), "%s" % ref[column])
            row += 1

        self.proxyModel.setSourceModel(self.model)

        self.setRootIsDecorated(False)
        self.setAlternatingRowColors(True)
        self.setModel(self.proxyModel)
        self.setSortingEnabled(True)
        self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)

        self.doubleClicked.connect(self.slotDoubleClicked) 
开发者ID:DroidTest,项目名称:TimeMachine,代码行数:36,代码来源:xrefwindow.py

示例9: __init__

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def __init__(self, parent=None, win=None, session=None):
        super(StringsValueWindow, self).__init__(parent)
        self.mainwin = win
        self.session = session
        self.title = "Strings"

        self.reverse_strings = {}

        self.proxyModel = QtGui.QSortFilterProxyModel()
        self.proxyModel.setDynamicSortFilter(True)

        self.model = QtGui.QStandardItemModel(self.session.get_nb_strings(), 4, self)

        self.model.setHeaderData(0, QtCore.Qt.Horizontal, "String")
        self.model.setHeaderData(1, QtCore.Qt.Horizontal, "Usage")
        self.model.setHeaderData(2, QtCore.Qt.Horizontal, "Filename")
        self.model.setHeaderData(3, QtCore.Qt.Horizontal, "Digest")

        row = 0
        for digest, filename, strings_analysis in self.session.get_strings():
            for string_value in strings_analysis:
                self.model.setData(self.model.index(row, 0, QtCore.QModelIndex()), repr(string_value))
                self.model.setData(self.model.index(row, 1, QtCore.QModelIndex()), len(strings_analysis[string_value].get_xref_from()))
                self.model.setData(self.model.index(row, 2, QtCore.QModelIndex()), filename)
                self.model.setData(self.model.index(row, 3, QtCore.QModelIndex()), digest)
                self.reverse_strings[repr(string_value) + digest] = strings_analysis[string_value]
                row += 1

        self.proxyModel.setSourceModel(self.model)


        self.setRootIsDecorated(False)
        self.setAlternatingRowColors(True)
        self.setModel(self.proxyModel)
        self.setSortingEnabled(True)
        self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)

        self.doubleClicked.connect(self.slotDoubleClicked) 
开发者ID:DroidTest,项目名称:TimeMachine,代码行数:40,代码来源:stringswindow.py

示例10: doneEditing

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def doneEditing(self):
        # This block signals needs to happen first otherwise I have lose focus
        # problems again when there are no rows
        self.line.blockSignals(True)
        self.line.setHidden(True)
        newname = str(self.line.text())
        self.model().setHeaderData(self.sectionedit, Qt.Orientation.Vertical, newname)
        self.line.setText('')
        self.setCurrentIndex(QtCore.QModelIndex()) 
开发者ID:ahmidou,项目名称:Fabric-RBF,代码行数:11,代码来源:CanvasRbfEditor.py

示例11: rowCount

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def rowCount(self, index=QtCore.QModelIndex()):
        return len(self.sub_signatures) 
开发者ID:Cisco-Talos,项目名称:CASC,代码行数:4,代码来源:casc_plugin.py

示例12: columnCount

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def columnCount(self, index=QtCore.QModelIndex()):
        return 4 
开发者ID:Cisco-Talos,项目名称:CASC,代码行数:4,代码来源:casc_plugin.py

示例13: getCustomRole

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def getCustomRole(self, model, index, role):
        '''
        Return data for a custom Qt Role

        :param QAbstractItemModel model: Active model
        :param QModelIndex index: Active index
        :param QRole role: Active role
        '''
        return None 
开发者ID:metalix00,项目名称:public,代码行数:11,代码来源:abstractModel.py

示例14: rowCount

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def rowCount(self, parent):
        '''
        Return number of rows for the item

        :param QModelIndex parent: index to query
        :returns: number of rows
        :rtype: int
        '''
        if parent.isValid():
            item = parent.internalPointer()

        else:
            item = self.__root

        return item.childCount() 
开发者ID:metalix00,项目名称:public,代码行数:17,代码来源:abstractModel.py

示例15: columnCount

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def columnCount(self, parent):
        '''
        Return number of columns for the item

        :param QModelIndex parent: index to query
        :returns: number of columns
        :rtype: int
        '''
        return len(self.__headers) 
开发者ID:metalix00,项目名称:public,代码行数:11,代码来源:abstractModel.py


注:本文中的PySide.QtCore.QModelIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。