本文整理汇总了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)
示例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
示例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)
示例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)
示例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
示例6: rowCount
# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def rowCount(self, index=QModelIndex()):
return self.df.shape[0]
示例7: columnCount
# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def columnCount(self, index=QModelIndex()):
return self.df.shape[1]
示例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)
示例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)
示例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())
示例11: rowCount
# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def rowCount(self, index=QtCore.QModelIndex()):
return len(self.sub_signatures)
示例12: columnCount
# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QModelIndex [as 别名]
def columnCount(self, index=QtCore.QModelIndex()):
return 4
示例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
示例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()
示例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)