Skip to content

Commit

Permalink
Index model children with QAbstractItemModel
Browse files Browse the repository at this point in the history
  • Loading branch information
YakoYakoYokuYoku committed Dec 14, 2021
1 parent 4801b02 commit ae82a12
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Gui/DopeSheetHierarchyView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ HierarchyViewSelectionModel::selectChildren(const QModelIndex &index,
QItemSelection *selection) const
{
int row = 0;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QModelIndex childIndex = index.model()->index(row, 0);
#else
QModelIndex childIndex = index.child(row, 0);
#endif

while ( childIndex.isValid() ) {
if ( !selection->contains(childIndex) ) {
Expand All @@ -143,7 +147,11 @@ HierarchyViewSelectionModel::selectChildren(const QModelIndex &index,
}

++row;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
childIndex = index.model()->index(row, 0);
#else
childIndex = index.child(row, 0);
#endif
}
}

Expand Down Expand Up @@ -187,7 +195,11 @@ HierarchyViewSelectionModel::checkParentsSelectedStates(const QModelIndex &index
QModelIndex index = (*it);
bool selectParent = true;
int row = 0;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QModelIndex childIndexIt = index.model()->index(row, 0);
#else
QModelIndex childIndexIt = index.child(row, 0);
#endif

while ( childIndexIt.isValid() ) {
if ( childIndexIt.data(QT_ROLE_CONTEXT_IS_ANIMATED).toBool() ) {
Expand All @@ -199,7 +211,11 @@ HierarchyViewSelectionModel::checkParentsSelectedStates(const QModelIndex &index
}

++row;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
childIndexIt = index.model()->index(row, 0);
#else
childIndexIt = index.child(row, 0);
#endif
}

if ( (flags & QItemSelectionModel::Select && selectParent) ) {
Expand Down Expand Up @@ -798,7 +814,11 @@ HierarchyView::drawRow(QPainter *painter,
painter->fillRect(itemRect.adjusted(-1, 0, 0, 0), fillColor);

// Draw the item text
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QStyleOptionViewItem newOpt = viewOptions();
#else
QStyleOptionViewItemV4 newOpt = viewOptions();
#endif
newOpt.rect = itemRect;

if ( selectionModel()->isSelected(index) ) {
Expand Down Expand Up @@ -848,7 +868,11 @@ HierarchyView::drawBranches(QPainter *painter,
painter->fillRect(rectForDull, nodeColorDull);

// Draw the branch indicator
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QStyleOptionViewItem option = viewOptions();
#else
QStyleOptionViewItemV4 option = viewOptions();
#endif
option.rect = _imp->getParentArrowRect(item, rect);
option.displayAlignment = Qt::AlignCenter;

Expand Down

0 comments on commit ae82a12

Please sign in to comment.