From 2e24d4b0cc5f0e3763ce9609544ecca1d477d31b Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 18 May 2021 09:17:18 +0200 Subject: [PATCH] Wizards: Fix generation of dynamically populated models This was implemented for QAbstractItemModel based classes, but forgotten for QAbstractListModel and QAbstractTableModel based classes. Change-Id: I807f445e48d2906580abd0a65bb794d6e766c1a7 Reviewed-by: Eike Ziller --- .../wizards/classes/itemmodel/listmodel.cpp | 18 ++++++++++++++++++ .../wizards/classes/itemmodel/listmodel.h | 8 ++++++++ .../wizards/classes/itemmodel/tablemodel.cpp | 18 ++++++++++++++++++ .../wizards/classes/itemmodel/tablemodel.h | 8 ++++++++ 4 files changed, 52 insertions(+) diff --git a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp index b6c9c4b430d..921267d015d 100644 --- a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp +++ b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp @@ -35,6 +35,24 @@ int %{CN}::rowCount(const QModelIndex &parent) const // FIXME: Implement me! } +@if %{DynamicFetch} + +bool %{CN}::hasChildren(const QModelIndex &parent) const +{ + // FIXME: Implement me! +} + +bool %{CN}::canFetchMore(const QModelIndex &parent) const +{ + // FIXME: Implement me! + return false; +} + +void %{CN}::fetchMore(const QModelIndex &parent) +{ + // FIXME: Implement me! +} +@endif QVariant %{CN}::data(const QModelIndex &index, int role) const { diff --git a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.h b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.h index 87812bdb595..fe1ef78cc61 100644 --- a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.h +++ b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.h @@ -28,6 +28,14 @@ public: // Basic functionality: int rowCount(const QModelIndex &parent = QModelIndex()) const override; +@if %{DynamicFetch} + // Fetch data dynamically: + bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; + + bool canFetchMore(const QModelIndex &parent) const override; + void fetchMore(const QModelIndex &parent) override; + +@endif QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; @if %{Editable} diff --git a/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp b/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp index cda910e6f76..e8c71f18bb9 100644 --- a/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp +++ b/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp @@ -42,6 +42,24 @@ int %{CN}::columnCount(const QModelIndex &parent) const // FIXME: Implement me! } +@if %{DynamicFetch} + +bool %{CN}::hasChildren(const QModelIndex &parent) const +{ + // FIXME: Implement me! +} + +bool %{CN}::canFetchMore(const QModelIndex &parent) const +{ + // FIXME: Implement me! + return false; +} + +void %{CN}::fetchMore(const QModelIndex &parent) +{ + // FIXME: Implement me! +} +@endif QVariant %{CN}::data(const QModelIndex &index, int role) const { diff --git a/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.h b/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.h index f6a0ad59c2f..b6293563064 100644 --- a/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.h +++ b/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.h @@ -29,6 +29,14 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; +@if %{DynamicFetch} + // Fetch data dynamically: + bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; + + bool canFetchMore(const QModelIndex &parent) const override; + void fetchMore(const QModelIndex &parent) override; + +@endif QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; @if %{Editable}