Python PySide.QtCore 模块,QModelIndex() 实例源码

我们从Python开源项目中,提取了以下24个代码示例,用于说明如何使用PySide.QtCore.QModelIndex()

项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def rowCount(self, parent=QtCore.QModelIndex()):
        return self.__db.get_number_of_people()
项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def rowCount(self, parent=QtCore.QModelIndex()):
        return len(self._famtrees)
项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def append_famtree(self, famtree):
        """
        Append a FamTreeWrapper to the family tree litsmodel
        """
        self.beginInsertRows(QtCore.QModelIndex(), self.rowCount(), self.rowCount())
        self._famtrees.append(famtree)
        self.endInsertRows()

#-------------------------------------------------------------------------
#
# DbManager
#
#-------------------------------------------------------------------------
项目:guiQML    作者:gramps-project    | 项目源码 | 文件源码
def rowCount(self, parent=QtCore.QModelIndex()):
        return len(self._detviews)
项目:smhr    作者:andycasey    | 项目源码 | 文件源码
def insertRow(self,row,parent=QtCore.QModelIndex()):
        self.beginInsertRows(parent,row,row)
        self.tab = np.insert(self.tab,row,['??','0','1.0'],axis=0)
        self.endInsertRows()
项目:smhr    作者:andycasey    | 项目源码 | 文件源码
def removeRow(self,row,parent=QtCore.QModelIndex()):
        self.beginRemoveRows(parent,row,row)
        self.tab = np.delete(self.tab,row,axis=0)
        self.endRemoveRows()
项目:smhr    作者:andycasey    | 项目源码 | 文件源码
def parent(self, index):
        if not index.isValid():
            return QtCore.QModelIndex()
        node = index.internalPointer()
        if node.parent is None:
            return QtCore.QModelIndex()
        else:
            return self.createIndex(node.parent.row, 0, node.parent)
项目:android_malware_detection    作者:congyuandong    | 项目源码 | 文件源码
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)
项目:android_malware_detection    作者:congyuandong    | 项目源码 | 文件源码
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)
项目:android_malware_detection    作者:congyuandong    | 项目源码 | 文件源码
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)
项目:android_malware_detection    作者:congyuandong    | 项目源码 | 文件源码
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)
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def rowCount(self, index=QModelIndex()):
        return self.df.shape[0]
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def columnCount(self, index=QModelIndex()):
        return self.df.shape[1]
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, sandbox, idx, *args, **kwargs):
            QtGui.QMenu.__init__(self, *args, **kwargs)
            self.sandbox = sandbox
            self.idx = idx

            def removeSource():
                self.sandbox.sources.removeSource(self.idx)

            def editSource():
                editing_dialog = self.sandbox.sources.data(
                    self.idx, SourceEditorDialog)
                editing_dialog.show()

            editAction = self.addAction(
                'Edit', editSource)

            self.addMenu(
                SourcesAddButton.SourcesAddMenu(self.sandbox, self))
            self.addSeparator()

            removeAction = self.addAction(
                self.style().standardPixmap(
                    QtGui.QStyle.SP_DialogCloseButton),
                'Remove', removeSource)

            if self.sandbox.sources.rowCount(QtCore.QModelIndex()) == 0:
                editAction.setEnabled(False)
                removeAction.setEnabled(False)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def addSourceROIS(self):
        self.rois = []
        index = QtCore.QModelIndex()
        for isrc in xrange(self.sandbox.sources.rowCount(index)):
            index = self.sandbox.sources.index(isrc, 0, index)
            roi = index.data(SourceROI)
            roi.setParent(self)
            self.rois.append(roi)
            self.addItem(roi)
项目:LCInterlocking    作者:execuc    | 项目源码 | 文件源码
def append_part(self, name, label, is_link=False):
        row = self.rootItem.child_count() - 1
        self.beginInsertRows(QtCore.QModelIndex(), row, row)
        part_type = TreeItem.PART_LINK if is_link else TreeItem.PART
        self.rootItem.append_child(TreeItem(part_type, [name, label], self.rootItem))
        self.endInsertRows()
        self.dataChanged.emit(QtCore.QModelIndex(), QtCore.QModelIndex())
        return self.index(self.rootItem.child_count()-1, 0, QtCore.QModelIndex())
项目:LCInterlocking    作者:execuc    | 项目源码 | 文件源码
def index(self, row, column, parent):
        if not self.hasIndex(row, column, parent):
            return QtCore.QModelIndex()

        if not parent.isValid():
            parent_item = self.rootItem
        else:
            parent_item = parent.internalPointer()

        child_item = parent_item.child(row)
        if child_item:
            return self.createIndex(row, column, child_item)
        else:
            return QtCore.QModelIndex()
项目:LCInterlocking    作者:execuc    | 项目源码 | 文件源码
def parent(self, index):
        if not index.isValid():
            return QtCore.QModelIndex()

        child_item = index.internalPointer()
        parent_item = child_item.parent()

        if parent_item == self.rootItem:
            return QtCore.QModelIndex()

        return self.createIndex(parent_item.row(), 0, parent_item)
项目:Fabric-RBF    作者:ahmidou    | 项目源码 | 文件源码
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())
项目:pcbre    作者:pcbre    | 项目源码 | 文件源码
def parent(self, index):
        node = self.index_get_node(index)
        p_obj = node.__adaptor_parent

        if p_obj is None:
            return QtCore.QModelIndex()

        row = self.node_row(p_obj)

        return self.createIndex(row, 0, p_obj)
项目:pcbre    作者:pcbre    | 项目源码 | 文件源码
def insert_keypoint(self, idx):
        """
        Returns a new keypoint inserted at index idx. Used for undos

        :param idx:
        :return:
        """
        self.combo_adapter.beginInsertRows(QtCore.QModelIndex(), idx, idx)
        self.__keypoints.insert(idx, AlignKeypoint())
        self.combo_adapter.endInsertRows()
        self.change()
项目:pcbre    作者:pcbre    | 项目源码 | 文件源码
def add_keypoint(self):
        """
        Adds a new keypoint. Returns the index of the new keypoint

        :return:
        """
        idx = len(self.__keypoints)
        self.combo_adapter.beginInsertRows(QtCore.QModelIndex(), idx, idx)
        self.__keypoints.append(AlignKeypoint())
        self.combo_adapter.endInsertRows()

        self.change()

        return idx
项目:pcbre    作者:pcbre    | 项目源码 | 文件源码
def del_keypoint(self, idx):
        """
        Delete a keypoint by index
        :param idx:
        :return:
        """
        # Refuse to delete existing keypoints
        if not self.keypoints[idx].is_new:
            return

        self.combo_adapter.beginRemoveRows(QtCore.QModelIndex(), idx, idx)
        del self.__keypoints[idx]
        self.combo_adapter.endRemoveRows()
        self.change()
项目:pcbre    作者:pcbre    | 项目源码 | 文件源码
def rowCount(self, parent=QtCore.QModelIndex()):
        b = len(self.p.stackup.layers)
        return b