aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quicktemplates2/qquickheaderview.cpp11
-rw-r--r--tests/auto/qquickheaderview/tst_qquickheaderview.cpp8
2 files changed, 14 insertions, 5 deletions
diff --git a/src/quicktemplates2/qquickheaderview.cpp b/src/quicktemplates2/qquickheaderview.cpp
index 85291bcb..d99c09eb 100644
--- a/src/quicktemplates2/qquickheaderview.cpp
+++ b/src/quicktemplates2/qquickheaderview.cpp
@@ -364,18 +364,22 @@ QModelIndex QHeaderDataProxyModel::parent(const QModelIndex &child) const
return QModelIndex();
}
-QModelIndex QHeaderDataProxyModel::sibling(int row, int column, const QModelIndex &idx) const
+QModelIndex QHeaderDataProxyModel::sibling(int row, int column, const QModelIndex &) const
{
- return index(row, column, idx);
+ return index(row, column);
}
int QHeaderDataProxyModel::rowCount(const QModelIndex &parent) const
{
+ if (parent.isValid())
+ return 0;
return m_model.isNull() ? -1 : (m_orientation == Qt::Horizontal ? 1 : m_model->rowCount(parent));
}
int QHeaderDataProxyModel::columnCount(const QModelIndex &parent) const
{
+ if (parent.isValid())
+ return 0;
return m_model.isNull() ? -1 : (m_orientation == Qt::Vertical ? 1 : m_model->columnCount(parent));
}
@@ -401,7 +405,8 @@ bool QHeaderDataProxyModel::setData(const QModelIndex &index, const QVariant &va
bool QHeaderDataProxyModel::hasChildren(const QModelIndex &parent) const
{
- Q_UNUSED(parent)
+ if (!parent.isValid())
+ return rowCount(parent) > 0 && columnCount(parent) > 0;
return false;
}
diff --git a/tests/auto/qquickheaderview/tst_qquickheaderview.cpp b/tests/auto/qquickheaderview/tst_qquickheaderview.cpp
index 611e39cb..f335aa86 100644
--- a/tests/auto/qquickheaderview/tst_qquickheaderview.cpp
+++ b/tests/auto/qquickheaderview/tst_qquickheaderview.cpp
@@ -58,8 +58,10 @@ public:
{
}
- int rowCount(const QModelIndex & = QModelIndex()) const override
+ int rowCount(const QModelIndex &index = QModelIndex()) const override
{
+ if (index.isValid())
+ return 0;
return m_rows;
}
virtual void setRowCount(int count)
@@ -70,8 +72,10 @@ public:
endResetModel();
}
- int columnCount(const QModelIndex & = QModelIndex()) const override
+ int columnCount(const QModelIndex &index = QModelIndex()) const override
{
+ if (index.isValid())
+ return 0;
return m_cols;
}
virtual void setColumnCount(int count)