當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。