def paintHorizontalSection(self, painter: QPainter, sectionRect: QRect, logicalLeafIndex: int, hv: QHeaderView, styleOptions: QStyleOptionHeader, leafIndex: QModelIndex): # print(logicalLeafIndex) oldBO = painter.brushOrigin() top = sectionRect.y() indexes = QModelIndexList(self.parentIndexes(leafIndex)) for i in range(indexes.size()): realStyleOptions = QStyleOptionHeader(styleOptions) if i < indexes.size() - 1 and ( realStyleOptions.state & QStyle.State_Sunken or realStyleOptions.state & QStyle.State_On): t = QStyle.State(QStyle.State_Sunken | QStyle.State_On) realStyleOptions.state = realStyleOptions.state & ~t # FIXME: parent items are not highlighted if i < indexes.size( ) - 1: # Use sortIndicator for inner level only realStyleOptions.sortIndicator = False # if i==0: # print(self.leafs(indexes[i]), leafIndex) top = self.paintHorizontalCell(painter, hv, indexes[i], leafIndex, logicalLeafIndex, realStyleOptions, sectionRect, top) painter.setBrushOrigin(oldBO)
def paintVerticalSection(self, painter: QPainter, sectionRect: QRect, logicalLeafIndex: int, hv: QHeaderView, styleOptions: QStyleOptionHeader, leafIndex: QModelIndex): oldBO = painter.brushOrigin() left = sectionRect.x() indexes = QModelIndexList(self.parentIndexes(leafIndex)) for i in range(indexes.size()): realStyleOptions = QStyleOptionHeader(styleOptions) if i < indexes.size() - 1 and ( realStyleOptions.state & QStyle.State_Sunken or realStyleOptions.state & QStyle.State_On): t = QStyle.State(QStyle.State_Sunken | QStyle.State_On) realStyleOptions.state = realStyleOptions.state & ~t # FIXME: parent items are not highlighted left = self.paintVerticalCell(painter, hv, indexes[i], leafIndex, logicalLeafIndex, realStyleOptions, sectionRect, left) painter.setBrushOrigin(oldBO)