summaryrefslogtreecommitdiffstats
path: root/examples/widgets/itemviews/simpletreemodel/treemodel.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-11-15 21:57:42 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-12-06 18:22:41 +0100
commita3e20df03d522bd1b07ac7a85578401f36f290b9 (patch)
treef4ed5be0841a6b38e16fd1fb4bf6ddee46eadc0a /examples/widgets/itemviews/simpletreemodel/treemodel.h
parent283cdcd3d5fad368c9df1bcae69cbfbf9ade623f (diff)
Polish the SimpleTreeModel example
- Fix/silence most clang-tidy/compiler warnings * unsigned/int comparison * Avoid repeating return / default parameter types * Make functions static/use static invocations * Use string literals everywhere * Use auto * for pointers * Streamline code, use ternary operators * Move constructor parameters * Observe rule of 5 by using Q_DISABLE_COPY_MOVE - Add some bells && whistles, resize properly, expand all Complements 25027444a9b53d61a6257dc5f5ce0ffdb3b06f98. Pick-to: 6.6 Change-Id: I78f48d187981ecabf69a5d4d42715bad026fa9e6 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Diffstat (limited to 'examples/widgets/itemviews/simpletreemodel/treemodel.h')
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treemodel.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/widgets/itemviews/simpletreemodel/treemodel.h b/examples/widgets/itemviews/simpletreemodel/treemodel.h
index 0a771088ed..55c72bb3bd 100644
--- a/examples/widgets/itemviews/simpletreemodel/treemodel.h
+++ b/examples/widgets/itemviews/simpletreemodel/treemodel.h
@@ -16,21 +16,23 @@ class TreeModel : public QAbstractItemModel
Q_OBJECT
public:
+ Q_DISABLE_COPY_MOVE(TreeModel)
+
explicit TreeModel(const QString &data, QObject *parent = nullptr);
- ~TreeModel();
+ ~TreeModel() override;
QVariant data(const QModelIndex &index, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column,
- const QModelIndex &parent = QModelIndex()) const override;
+ const QModelIndex &parent = {}) const override;
QModelIndex parent(const QModelIndex &index) const override;
- int rowCount(const QModelIndex &parent = QModelIndex()) const override;
- int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ int rowCount(const QModelIndex &parent = {}) const override;
+ int columnCount(const QModelIndex &parent = {}) const override;
private:
- void setupModelData(const QStringList &lines, TreeItem *parent);
+ static void setupModelData(const QStringList &lines, TreeItem *parent);
std::unique_ptr<TreeItem> rootItem;
};