Python qtpy.QtCore.QModelIndex() Examples

The following are 12 code examples of qtpy.QtCore.QModelIndex(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module qtpy.QtCore , or try the search function .
Example #1
Source File: datatree.py    From spyder-unittest with MIT License 6 votes vote down vote up
def add_testresults(self, new_tests):
        """
        Add new test results to the model.

        Arguments
        ---------
        new_tests : list of TestResult
        """
        firstRow = len(self.testresults)
        lastRow = firstRow + len(new_tests) - 1
        for test in new_tests:
            self.abbreviator.add(test.name)
        self.beginInsertRows(QModelIndex(), firstRow, lastRow)
        self.testresults.extend(new_tests)
        self.endInsertRows()
        self.emit_summary() 
Example #2
Source File: icon_browser.py    From qtawesome with MIT License 6 votes vote down vote up
def data(self, index, role):
        """
        Re-implemented to return the icon for the current index.

        Parameters
        ----------
        index : QtCore.QModelIndex
        role : int

        Returns
        -------
        Any
        """
        if role == QtCore.Qt.DecorationRole:
            iconString = self.data(index, role=QtCore.Qt.DisplayRole)
            return qtawesome.icon(iconString, color=self._iconColor)
        return super().data(index, role) 
Example #3
Source File: datatree.py    From spyder-unittest with MIT License 5 votes vote down vote up
def index(self, row, column, parent=QModelIndex()):
        """
        Construct index to given item of data.

        If `parent` not valid, then the item of data is on the top level.
        """
        if not self.hasIndex(row, column, parent):  # check bounds etc.
            return QModelIndex()
        if not parent.isValid():
            return self.createIndex(row, column, TOPLEVEL_ID)
        else:
            testresult_index = parent.row()
            return self.createIndex(row, column, testresult_index) 
Example #4
Source File: datatree.py    From spyder-unittest with MIT License 5 votes vote down vote up
def parent(self, index):
        """Return index to parent of item that `index` points to."""
        if not index.isValid():
            return QModelIndex()
        id = index.internalId()
        if id == TOPLEVEL_ID:
            return QModelIndex()
        else:
            return self.index(id, 0) 
Example #5
Source File: datatree.py    From spyder-unittest with MIT License 5 votes vote down vote up
def rowCount(self, parent=QModelIndex()):
        """Return number of rows underneath `parent`."""
        if not parent.isValid():
            return len(self.testresults)
        if parent.internalId() == TOPLEVEL_ID and parent.column() == 0:
            return len(self.testresults[parent.row()].extra_text)
        return 0 
Example #6
Source File: datatree.py    From spyder-unittest with MIT License 5 votes vote down vote up
def columnCount(self, parent=QModelIndex()):
        """Return number of rcolumns underneath `parent`."""
        if not parent.isValid():
            return len(HEADERS)
        else:
            return 1 
Example #7
Source File: DepotClientViewModel.py    From P4VFX with MIT License 5 votes vote down vote up
def index(self, row, column, parent):
        if not self.hasIndex(row, column, parent):
            return QtCore.QModelIndex()

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

        childItem = parentItem.childItems[row]
        if childItem:
            return self.createIndex(row, column, childItem)
        else:
            return QtCore.QModelIndex() 
Example #8
Source File: DepotClientViewModel.py    From P4VFX with MIT License 5 votes vote down vote up
def parent(self, index):
        if not index.isValid():
            return QtCore.QModelIndex()
        parentItem = index.internalPointer().parentItem
        if parentItem == self.rootItem:
            return QtCore.QModelIndex()
        return self.createIndex(parentItem.row(), 0, parentItem) 
Example #9
Source File: DepotClientViewModel.py    From P4VFX with MIT License 5 votes vote down vote up
def index(self, row, column, parent):
        if not self.hasIndex(row, column, parent):
            return QtCore.QModelIndex()

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

        childItem = parentItem.childItems[row]
        if childItem:
            return self.createIndex(row, column, childItem)
        else:
            return QtCore.QModelIndex() 
Example #10
Source File: DepotClientViewModel.py    From P4VFX with MIT License 5 votes vote down vote up
def parent(self, index):
        if not index.isValid():
            return QtCore.QModelIndex()
        parentItem = index.internalPointer().parentItem
        if parentItem == self.rootItem:
            return QtCore.QModelIndex()
        return self.createIndex(parentItem.row(), 0, parentItem) 
Example #11
Source File: dependencies.py    From conda-manager with MIT License 5 votes vote down vote up
def rowCount(self, index=QModelIndex()):
        """Override Qt method."""
        return len(self._rows) 
Example #12
Source File: dependencies.py    From conda-manager with MIT License 5 votes vote down vote up
def columnCount(self, index=QModelIndex()):
        """Override Qt method."""
        return 4