summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2016-08-08 15:32:56 +0200
committerDavid Faure <david.faure@kdab.com>2016-08-10 16:13:40 +0000
commit252a3f89c61ae9a14427f66788b26597e6d24a6c (patch)
tree448b48677fe52f1ce7b5c91191e4255948e717de
parent7f07ec41abb8194cafa19863af183e5e7f971edf (diff)
downloadqt-creator-252a3f89c61ae9a14427f66788b26597e6d24a6c.tar.gz
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>
-rw-r--r--share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp2
-rw-r--r--share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp
index 5d7fa72875..2881513ab6 100644
--- a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp
+++ b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp
@@ -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!
diff --git a/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp b/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp
index fb452feace..80bedf5899 100644
--- a/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp
+++ b/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp
@@ -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!