Fix wrong code in list/table model templates

rowCount should return 0 if the parent *is* valid, and return
the actual number of rows when queried with an invalid index.

Change-Id: I00e3d4ea79e1aaf0be1974da876c5a871d3924e6
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
David Faure
2016-08-08 15:32:56 +02:00
parent 7f07ec41ab
commit 252a3f89c6
2 changed files with 3 additions and 3 deletions

View File

@@ -28,7 +28,7 @@ bool %{CN}::setHeaderData(int section, Qt::Orientation orientation, const QVaria
int %{CN}::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid())
if (parent.isValid())
return 0;
// FIXME: Implement me!

View File

@@ -29,7 +29,7 @@ bool %{CN}::setHeaderData(int section, Qt::Orientation orientation, const QVaria
int %{CN}::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid())
if (parent.isValid())
return 0;
// FIXME: Implement me!
@@ -37,7 +37,7 @@ int %{CN}::rowCount(const QModelIndex &parent) const
int %{CN}::columnCount(const QModelIndex &parent) const
{
if (!parent.isValid())
if (parent.isValid())
return 0;
// FIXME: Implement me!