diff options
author | Lorenz Haas <lorenz.haas@histomatics.de> | 2016-07-28 07:30:06 +0200 |
---|---|---|
committer | Lorenz Haas <lorenz.haas@histomatics.de> | 2016-07-31 09:23:38 +0000 |
commit | 69143bc3a915a70346df43c9c7ae52f6992f0f17 (patch) | |
tree | 558067abc24768f9815c20ee1880a442da9599bc /share | |
parent | f41e1d3a31353b5cd2f843ae3d875504ad5d1998 (diff) | |
download | qt-creator-69143bc3a915a70346df43c9c7ae52f6992f0f17.tar.gz |
Wizards: Fix list model wizard's rowCount()
rowCount() must return 0 when the parent is valid: this indicates that
the list's items has no children and thus it is no tree model. The
list's size has to be returned for an invalid parent (== the invisible
root node).
Change-Id: Ieaa884958ea0094aca2232160b6f769bf90514c4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'share')
-rw-r--r-- | share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp index 5d7fa72875..5d25d88609 100644 --- a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp +++ b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp @@ -28,7 +28,9 @@ bool %{CN}::setHeaderData(int section, Qt::Orientation orientation, const QVaria int %{CN}::rowCount(const QModelIndex &parent) const { - if (!parent.isValid()) + // For list models only the root node (an invalid parent) should return the list's size. For all + // other (valid) parents, rowCount() should return 0 so that it does not become a tree model. + if (parent.isValid()) return 0; // FIXME: Implement me! |