From 4c35909d3dbe76228417d495c79d0a51ebb7bb6f Mon Sep 17 00:00:00 2001 From: Daguerreo Date: Mon, 17 Jan 2022 15:50:07 +0100 Subject: [PATCH 1/8] Updated documentation --- plugin/tree_item.h | 20 +++++++++++++++++++- plugin/tree_model.h | 22 +++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/plugin/tree_item.h b/plugin/tree_item.h index 82d9db1..b586fbc 100644 --- a/plugin/tree_item.h +++ b/plugin/tree_item.h @@ -28,23 +28,41 @@ #include /*! - * This class represents a node of the TreeModel + * This class represents a node of the TreeModel. + * The items are meant to be managed from the TreeModel, thus is only allowed + * to modify the stored data. + * Parenting and deletion are dealt from the TreeModel. Deleting a TreeItem + * will call the delete for each child node. */ class TreeItem { friend class TreeModel; public: + //! Create an empty item. TreeItem(); + + //! Create an item with the given data. explicit TreeItem(const QVariant& data); + + //! Destroy the item. It will destroy every child. ~TreeItem(); + //! Return the stored data of the node. const QVariant& data() const; + + //! Set the internal data of the node. void setData(const QVariant& data); + //! Return the number of children nodes. int childCount() const; + int row() const; + + //! Return true if the node is a leaf node (no children). bool isLeaf() const; + + //! Return the depth of this node inside the tree. int depth() const; private: diff --git a/plugin/tree_model.h b/plugin/tree_model.h index ef459bc..676f37a 100644 --- a/plugin/tree_model.h +++ b/plugin/tree_model.h @@ -29,6 +29,10 @@ #include "tree_item.h" +/*! + * The Tree Model works as List Model, using one column and using the row information + * referred to the parent node. + */ class TreeModel : public QAbstractItemModel { Q_OBJECT @@ -37,6 +41,8 @@ class TreeModel : public QAbstractItemModel explicit TreeModel(QObject* parent = nullptr); ~TreeModel() override; + // Overriden method from QAbstractItemModel + public: int rowCount(const QModelIndex& index) const override; int columnCount(const QModelIndex& index) const override; @@ -48,16 +54,30 @@ class TreeModel : public QAbstractItemModel bool setData(const QModelIndex& index, const QVariant& value, int role=Qt::EditRole) override; public: + //! Add an item to the top level. void addTopLevelItem(TreeItem* child); + + //! Add a child to the parent item. void addItem(TreeItem* parent, TreeItem* child); + + //! Remove the item from the model. void removeItem(TreeItem* item); + //! Return the root item of the model. TreeItem* rootItem() const; - Q_INVOKABLE QModelIndex rootIndex(); + //! Return the depth for the given index Q_INVOKABLE int depth(const QModelIndex& index) const; + + //! Clear the model. Q_INVOKABLE void clear(); + /*! + * Return the root item to the QML Side. + * This method is not meant to be used in client code. + */ + Q_INVOKABLE QModelIndex rootIndex(); + private: TreeItem* internalPointer(const QModelIndex& index) const; From 930f35434dc459fa8227ed6fee60fb2efad32aa1 Mon Sep 17 00:00:00 2001 From: Daguerreo Date: Wed, 11 Jan 2023 18:47:50 +0100 Subject: [PATCH 2/8] Update README --- QMLTreeView.pro | 5 +++-- README.md | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/QMLTreeView.pro b/QMLTreeView.pro index 03da9fa..1d3ed49 100644 --- a/QMLTreeView.pro +++ b/QMLTreeView.pro @@ -3,5 +3,6 @@ TEMPLATE = subdirs SUBDIRS += \ examples -DISTFILES += \ - $$files(modules/QMLTreeView/*) +OTHER_FILES += \ + $$files(modules/QMLTreeView/*) \ + README.md diff --git a/README.md b/README.md index e556e24..1cc21c1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ -# QMLTreeView 1.0 +# QMLTreeView for Qt 5 This project provides a **QML Tree View** with a **C++ Tree Model** for **Qt 5.15** and **QuickControls 2**. +Since **Qt 6.3** [TreeView](https://doc.qt.io/qt-6/qml-qtquick-treeview.html) it's a standard component with easy use, +so refers to that for Qt 6. + ## Features - QML Tree View - C++ Tree Model From 46736197656f330bb5149b72664dc0e51d345559 Mon Sep 17 00:00:00 2001 From: Daguerreo Date: Tue, 5 Sep 2023 10:20:55 +0200 Subject: [PATCH 3/8] Update .gitignore --- .gitignore | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a751ba4..1b55cb5 100644 --- a/.gitignore +++ b/.gitignore @@ -37,9 +37,12 @@ Makefile* *.out *.app -# Qt +# Qt +.qtc_clangd *.pro.user* *.qmlproject.user **.qmake.stash **moc_predefs.h -**/build + +# Build +**/build* From adea17d29b71d6fd99d741f83c72fd43722200bd Mon Sep 17 00:00:00 2001 From: Daguerreo Date: Tue, 5 Sep 2023 10:35:58 +0200 Subject: [PATCH 4/8] Added .clang-format and .gitattributes --- .clang-format | 103 +++++++++++++++++++ .gitattributes | 268 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 371 insertions(+) create mode 100644 .clang-format create mode 100644 .gitattributes diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..d8b7175 --- /dev/null +++ b/.clang-format @@ -0,0 +1,103 @@ +--- +AccessModifierOffset: '-4' +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: 'false' +AlignConsecutiveDeclarations: 'false' +AlignEscapedNewlines: DontAlign +AlignOperands: 'true' +AlignTrailingComments: 'true' +AllowAllParametersOfDeclarationOnNextLine: 'true' +AllowShortBlocksOnASingleLine: 'false' +AllowShortCaseLabelsOnASingleLine: 'false' +AllowShortEnumsOnASingleLine: 'false' +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Inline +AllowShortLoopsOnASingleLine: 'false' +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: 'false' +AlwaysBreakTemplateDeclarations: 'Yes' +BinPackArguments: 'false' +BinPackParameters: 'false' +BraceWrapping: + AfterClass: 'true' + AfterControlStatement: 'false' + AfterEnum: 'false' + AfterFunction: 'true' + AfterNamespace: 'false' + AfterObjCDeclaration: 'false' + AfterStruct: 'true' + AfterUnion: 'false' + BeforeCatch: 'false' + BeforeElse: 'false' + IndentBraces: 'false' + SplitEmptyFunction: 'false' + SplitEmptyRecord: 'false' + SplitEmptyNamespace: 'false' +BreakAfterJavaFieldAnnotations: 'false' +BreakBeforeBinaryOperators: All +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: 'true' +BreakConstructorInitializers: BeforeComma +BreakInheritanceList: BeforeComma +BreakStringLiterals: 'true' +ColumnLimit: '120' +CommentPragmas: '''^ IWYU pragma:''' +CompactNamespaces: 'false' +ConstructorInitializerAllOnOneLineOrOnePerLine: 'false' +ConstructorInitializerIndentWidth: '4' +ContinuationIndentWidth: '4' +Cpp11BracedListStyle: 'true' +DerivePointerAlignment: 'false' +DisableFormat: 'false' +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: 'false' +FixNamespaceComments: 'true' +ForEachMacros: ['forever','foreach','Q_FOREACH','BOOST_FOREACH'] +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^ Date: Tue, 5 Sep 2023 10:36:56 +0200 Subject: [PATCH 5/8] Formatted code with .clang-format options --- examples/customdelegate/main.cpp | 103 ++++++------ examples/json/json_entry.cpp | 42 ++--- examples/json/json_entry.h | 36 ++--- examples/json/main.cpp | 140 ++++++++-------- examples/manipulator/main.cpp | 45 +++--- examples/manipulator/tree_manipulator.cpp | 43 +++-- examples/manipulator/tree_manipulator.h | 18 +-- examples/minimal/main.cpp | 103 ++++++------ examples/styled/main.cpp | 103 ++++++------ modules/QMLTreeView/tree_item.cpp | 67 ++++---- modules/QMLTreeView/tree_item.h | 52 +++--- modules/QMLTreeView/tree_model.cpp | 188 +++++++++++----------- modules/QMLTreeView/tree_model.h | 56 +++---- 13 files changed, 500 insertions(+), 496 deletions(-) diff --git a/examples/customdelegate/main.cpp b/examples/customdelegate/main.cpp index 062d709..4957605 100644 --- a/examples/customdelegate/main.cpp +++ b/examples/customdelegate/main.cpp @@ -1,61 +1,64 @@ +#include "tree_model.h" + #include #include #include -#include "tree_model.h" - void populateModel(TreeModel& model) { - auto america = new TreeItem("America"); - auto asia = new TreeItem("Asia"); - auto europe = new TreeItem("Europe"); - auto oceania = new TreeItem("Oceania"); - - auto brazil = new TreeItem("Brazil"); - auto canada = new TreeItem("Canada"); - auto mexico = new TreeItem("Mexico"); - auto usa = new TreeItem("USA"); - - auto italy = new TreeItem("Italy"); - auto france = new TreeItem("France"); - auto portugal = new TreeItem("Portugal"); - auto spain = new TreeItem("Spain"); - - model.addTopLevelItem(america); - model.addTopLevelItem(asia); - model.addTopLevelItem(europe); - model.addTopLevelItem(oceania); - model.addItem(america, brazil); - model.addItem(america, canada); - model.addItem(america, mexico); - model.addItem(america, usa); - model.addItem(europe, italy); - model.addItem(europe, france); - model.addItem(europe, portugal); - model.addItem(europe, spain); + auto america = new TreeItem("America"); + auto asia = new TreeItem("Asia"); + auto europe = new TreeItem("Europe"); + auto oceania = new TreeItem("Oceania"); + + auto brazil = new TreeItem("Brazil"); + auto canada = new TreeItem("Canada"); + auto mexico = new TreeItem("Mexico"); + auto usa = new TreeItem("USA"); + + auto italy = new TreeItem("Italy"); + auto france = new TreeItem("France"); + auto portugal = new TreeItem("Portugal"); + auto spain = new TreeItem("Spain"); + + model.addTopLevelItem(america); + model.addTopLevelItem(asia); + model.addTopLevelItem(europe); + model.addTopLevelItem(oceania); + model.addItem(america, brazil); + model.addItem(america, canada); + model.addItem(america, mexico); + model.addItem(america, usa); + model.addItem(europe, italy); + model.addItem(europe, france); + model.addItem(europe, portugal); + model.addItem(europe, spain); } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) +{ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif - QGuiApplication app(argc, argv); - QQmlApplicationEngine engine; - engine.addImportPath("qrc:/modules"); - - auto treeModel = new TreeModel(&engine); - populateModel(*treeModel); - - engine.rootContext()->setContextProperty("treeModel", treeModel); - const QUrl url(QStringLiteral("qrc:/main.qml")); - QObject::connect( - &engine, &QQmlApplicationEngine::objectCreated, &app, - [url](QObject *obj, const QUrl &objUrl) { - if (!obj && url == objUrl) QCoreApplication::exit(-1); - }, - Qt::QueuedConnection); - engine.load(url); - - return app.exec(); -} + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + engine.addImportPath("qrc:/modules"); + auto treeModel = new TreeModel(&engine); + populateModel(*treeModel); + + engine.rootContext()->setContextProperty("treeModel", treeModel); + const QUrl url(QStringLiteral("qrc:/main.qml")); + QObject::connect( + &engine, + &QQmlApplicationEngine::objectCreated, + &app, + [url](QObject* obj, const QUrl& objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, + Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +} diff --git a/examples/json/json_entry.cpp b/examples/json/json_entry.cpp index 74ee0b9..bb28561 100644 --- a/examples/json/json_entry.cpp +++ b/examples/json/json_entry.cpp @@ -1,65 +1,65 @@ #include "json_entry.h" JsonEntry::JsonEntry() - : _type(QJsonValue::Null) -{ -} + : _type(QJsonValue::Null) +{} JsonEntry::JsonEntry(const QString& key, const QVariant& value, QJsonValue::Type type) - : _key(key), _value(value), _type(type) -{ -} + : _key(key) + , _value(value) + , _type(type) +{} QString JsonEntry::key() const { - return _key; + return _key; } QVariant JsonEntry::value() const { - return _value; + return _value; } QJsonValue::Type JsonEntry::type() const { - return _type; + return _type; } void JsonEntry::setKey(QString key) { - if (_key == key) - return; + if (_key == key) + return; - _key = key; + _key = key; } void JsonEntry::setValue(QVariant value) { - if (_value == value) - return; + if (_value == value) + return; - _value = value; + _value = value; } void JsonEntry::setType(QJsonValue::Type type) { - if (_type == type) - return; + if (_type == type) + return; - _type = type; + _type = type; } bool JsonEntry::isObject() const { - return _type == QJsonValue::Object; + return _type == QJsonValue::Object; } bool JsonEntry::isArray() const { - return _type == QJsonValue::Array; + return _type == QJsonValue::Array; } bool JsonEntry::isValue() const { - return !(isObject() || isArray()); + return !(isObject() || isArray()); } diff --git a/examples/json/json_entry.h b/examples/json/json_entry.h index b0ef1b1..74d529f 100644 --- a/examples/json/json_entry.h +++ b/examples/json/json_entry.h @@ -5,32 +5,32 @@ class JsonEntry { - Q_GADGET - Q_PROPERTY(QString key READ key WRITE setKey) - Q_PROPERTY(QVariant value READ value WRITE setValue) - Q_PROPERTY(QJsonValue::Type type READ type WRITE setType) + Q_GADGET + Q_PROPERTY(QString key READ key WRITE setKey) + Q_PROPERTY(QVariant value READ value WRITE setValue) + Q_PROPERTY(QJsonValue::Type type READ type WRITE setType) public: - JsonEntry(); - JsonEntry(const QString& key, const QVariant& value, QJsonValue::Type type); + JsonEntry(); + JsonEntry(const QString& key, const QVariant& value, QJsonValue::Type type); - QString key() const; - void setKey(QString key); + QString key() const; + void setKey(QString key); - QVariant value() const; - void setValue(QVariant value); + QVariant value() const; + void setValue(QVariant value); - QJsonValue::Type type() const; - void setType(QJsonValue::Type type); + QJsonValue::Type type() const; + void setType(QJsonValue::Type type); - Q_INVOKABLE bool isObject() const; - Q_INVOKABLE bool isArray() const; - Q_INVOKABLE bool isValue() const; + Q_INVOKABLE bool isObject() const; + Q_INVOKABLE bool isArray() const; + Q_INVOKABLE bool isValue() const; private: - QString _key; - QVariant _value; - QJsonValue::Type _type; + QString _key; + QVariant _value; + QJsonValue::Type _type; }; Q_DECLARE_METATYPE(JsonEntry) diff --git a/examples/json/main.cpp b/examples/json/main.cpp index 27dc96b..2fe55ed 100644 --- a/examples/json/main.cpp +++ b/examples/json/main.cpp @@ -1,95 +1,93 @@ -#include -#include -#include +#include "json_entry.h" +#include "tree_model.h" #include +#include #include #include #include - -#include "tree_model.h" -#include "json_entry.h" +#include +#include void loadValue(const QJsonValue& value, TreeItem* parent, TreeModel* model) { - if(value.isObject()) { - auto object = value.toObject(); - for(auto it=object.begin(); it!=object.end(); ++it){ - JsonEntry entry; - entry.setKey(it.key()); - entry.setType(QJsonValue::Object); - if(it.value().isArray() || it.value().isObject()){ - auto child = new TreeItem(QVariant::fromValue(entry)); - loadValue(it.value(), child, model); - model->addItem(parent, child); - } - else { - entry.setValue(it.value().toVariant()); + if (value.isObject()) { + auto object = value.toObject(); + for (auto it = object.begin(); it != object.end(); ++it) { + JsonEntry entry; + entry.setKey(it.key()); + entry.setType(QJsonValue::Object); + if (it.value().isArray() || it.value().isObject()) { + auto child = new TreeItem(QVariant::fromValue(entry)); + loadValue(it.value(), child, model); + model->addItem(parent, child); + } else { + entry.setValue(it.value().toVariant()); + auto child = new TreeItem(QVariant::fromValue(entry)); + model->addItem(parent, child); + } + } + } else if (value.isArray()) { + int index = 0; + auto array = value.toArray(); + for (auto&& element : array) { + JsonEntry entry; + entry.setKey("[" + QString::number(index) + "]"); + entry.setType(QJsonValue::Array); auto child = new TreeItem(QVariant::fromValue(entry)); model->addItem(parent, child); - } - } - } - else if(value.isArray()){ - int index = 0; - auto array = value.toArray(); - for(auto&& element: array){ - JsonEntry entry; - entry.setKey("[" + QString::number(index) + "]"); - entry.setType(QJsonValue::Array); - auto child = new TreeItem(QVariant::fromValue(entry)); - model->addItem(parent, child); - loadValue(element, child, model); - ++index; - } - } - else { - JsonEntry entry; - entry.setValue(value.toVariant()); - entry.setType(value.type()); - auto child = new TreeItem(QVariant::fromValue(entry)); - model->addItem(parent, child); - } + loadValue(element, child, model); + ++index; + } + } else { + JsonEntry entry; + entry.setValue(value.toVariant()); + entry.setType(value.type()); + auto child = new TreeItem(QVariant::fromValue(entry)); + model->addItem(parent, child); + } } void populateModel(TreeModel& model) { - QFile jsonFile{":/sample.json"}; - if(!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)){ - qCritical() << "error: json file cannot be open"; - return; - } + QFile jsonFile{":/sample.json"}; + if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + qCritical() << "error: json file cannot be open"; + return; + } - QJsonParseError error; - auto doc = QJsonDocument::fromJson(jsonFile.readAll(), &error); - qDebug() << "loading json file:" << error.errorString(); + QJsonParseError error; + auto doc = QJsonDocument::fromJson(jsonFile.readAll(), &error); + qDebug() << "loading json file:" << error.errorString(); - auto root = doc.isArray() ? QJsonValue(doc.array()) : QJsonValue(doc.object()); - loadValue(root, model.rootItem(), &model); + auto root = doc.isArray() ? QJsonValue(doc.array()) : QJsonValue(doc.object()); + loadValue(root, model.rootItem(), &model); } - -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) +{ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif - QGuiApplication app(argc, argv); - QQmlApplicationEngine engine; - engine.addImportPath("qrc:/modules"); + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + engine.addImportPath("qrc:/modules"); - auto jsonModel = new TreeModel(&engine); - populateModel(*jsonModel); + auto jsonModel = new TreeModel(&engine); + populateModel(*jsonModel); - engine.rootContext()->setContextProperty("jsonModel", jsonModel); - const QUrl url(QStringLiteral("qrc:/main.qml")); - QObject::connect( - &engine, &QQmlApplicationEngine::objectCreated, &app, - [url](QObject *obj, const QUrl &objUrl) { - if (!obj && url == objUrl) QCoreApplication::exit(-1); - }, - Qt::QueuedConnection); - engine.load(url); + engine.rootContext()->setContextProperty("jsonModel", jsonModel); + const QUrl url(QStringLiteral("qrc:/main.qml")); + QObject::connect( + &engine, + &QQmlApplicationEngine::objectCreated, + &app, + [url](QObject* obj, const QUrl& objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, + Qt::QueuedConnection); + engine.load(url); - return app.exec(); + return app.exec(); } - diff --git a/examples/manipulator/main.cpp b/examples/manipulator/main.cpp index 42bc9d3..83876a1 100644 --- a/examples/manipulator/main.cpp +++ b/examples/manipulator/main.cpp @@ -1,32 +1,35 @@ +#include "tree_manipulator.h" +#include "tree_model.h" + #include #include #include -#include "tree_model.h" -#include "tree_manipulator.h" - - -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) +{ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif - QGuiApplication app(argc, argv); - QQmlApplicationEngine engine; - engine.addImportPath("qrc:/modules"); + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + engine.addImportPath("qrc:/modules"); - auto treeModel = new TreeModel(&engine); - auto treeManipulator = new TreeManipulator(*treeModel, &engine); + auto treeModel = new TreeModel(&engine); + auto treeManipulator = new TreeManipulator(*treeModel, &engine); - engine.rootContext()->setContextProperty("treeManipulator", QVariant::fromValue(treeManipulator)); + engine.rootContext()->setContextProperty("treeManipulator", QVariant::fromValue(treeManipulator)); - const QUrl url(QStringLiteral("qrc:/main.qml")); - QObject::connect( - &engine, &QQmlApplicationEngine::objectCreated, &app, - [url](QObject *obj, const QUrl &objUrl) { - if (!obj && url == objUrl) QCoreApplication::exit(-1); - }, - Qt::QueuedConnection); - engine.load(url); + const QUrl url(QStringLiteral("qrc:/main.qml")); + QObject::connect( + &engine, + &QQmlApplicationEngine::objectCreated, + &app, + [url](QObject* obj, const QUrl& objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, + Qt::QueuedConnection); + engine.load(url); - return app.exec(); + return app.exec(); } diff --git a/examples/manipulator/tree_manipulator.cpp b/examples/manipulator/tree_manipulator.cpp index 6cd242a..b581cde 100644 --- a/examples/manipulator/tree_manipulator.cpp +++ b/examples/manipulator/tree_manipulator.cpp @@ -1,53 +1,52 @@ +#include "tree_item.h" #include "tree_manipulator.h" #include "tree_model.h" -#include "tree_item.h" TreeManipulator::TreeManipulator(TreeModel& model, QObject* parent) - : QObject(parent), - _model(&model) -{ -} + : QObject(parent) + , _model(&model) +{} QVariant TreeManipulator::sourceModel() const { - return QVariant::fromValue(_model); + return QVariant::fromValue(_model); } void TreeManipulator::addTopLevelItem(const QString& data) { - _model->addTopLevelItem(new TreeItem(data)); + _model->addTopLevelItem(new TreeItem(data)); } void TreeManipulator::addItem(const QModelIndex& index, const QString& data) { - if(!index.isValid()){ - return; - } + if (!index.isValid()) { + return; + } - auto parent = static_cast(index.internalPointer()); - _model->addItem(parent, new TreeItem(data)); + auto parent = static_cast(index.internalPointer()); + _model->addItem(parent, new TreeItem(data)); } void TreeManipulator::removeItem(const QModelIndex& index) { - if(!index.isValid()){ - return; - } + if (!index.isValid()) { + return; + } - auto item = static_cast(index.internalPointer()); - _model->removeItem(item); + auto item = static_cast(index.internalPointer()); + _model->removeItem(item); } void TreeManipulator::editItem(const QModelIndex& index, const QString& data) { - if(!index.isValid()){ - return; - } + if (!index.isValid()) { + return; + } - _model->setData(index, data); + _model->setData(index, data); } void TreeManipulator::reset() { - _model->clear(); + _model->clear(); } diff --git a/examples/manipulator/tree_manipulator.h b/examples/manipulator/tree_manipulator.h index bd2db75..5b37cfc 100644 --- a/examples/manipulator/tree_manipulator.h +++ b/examples/manipulator/tree_manipulator.h @@ -11,20 +11,20 @@ class TreeModel; */ class TreeManipulator : public QObject { - Q_OBJECT + Q_OBJECT public: - explicit TreeManipulator(TreeModel& model, QObject* parent = nullptr); + explicit TreeManipulator(TreeModel& model, QObject* parent = nullptr); - Q_INVOKABLE QVariant sourceModel() const; - Q_INVOKABLE void addTopLevelItem(const QString& data); - Q_INVOKABLE void addItem(const QModelIndex& index, const QString& data); - Q_INVOKABLE void removeItem(const QModelIndex& index); - Q_INVOKABLE void editItem(const QModelIndex& index, const QString& data); - Q_INVOKABLE void reset(); + Q_INVOKABLE QVariant sourceModel() const; + Q_INVOKABLE void addTopLevelItem(const QString& data); + Q_INVOKABLE void addItem(const QModelIndex& index, const QString& data); + Q_INVOKABLE void removeItem(const QModelIndex& index); + Q_INVOKABLE void editItem(const QModelIndex& index, const QString& data); + Q_INVOKABLE void reset(); private: - TreeModel* _model; + TreeModel* _model; }; #endif // TREE_MANIPULATOR_H diff --git a/examples/minimal/main.cpp b/examples/minimal/main.cpp index 062d709..4957605 100644 --- a/examples/minimal/main.cpp +++ b/examples/minimal/main.cpp @@ -1,61 +1,64 @@ +#include "tree_model.h" + #include #include #include -#include "tree_model.h" - void populateModel(TreeModel& model) { - auto america = new TreeItem("America"); - auto asia = new TreeItem("Asia"); - auto europe = new TreeItem("Europe"); - auto oceania = new TreeItem("Oceania"); - - auto brazil = new TreeItem("Brazil"); - auto canada = new TreeItem("Canada"); - auto mexico = new TreeItem("Mexico"); - auto usa = new TreeItem("USA"); - - auto italy = new TreeItem("Italy"); - auto france = new TreeItem("France"); - auto portugal = new TreeItem("Portugal"); - auto spain = new TreeItem("Spain"); - - model.addTopLevelItem(america); - model.addTopLevelItem(asia); - model.addTopLevelItem(europe); - model.addTopLevelItem(oceania); - model.addItem(america, brazil); - model.addItem(america, canada); - model.addItem(america, mexico); - model.addItem(america, usa); - model.addItem(europe, italy); - model.addItem(europe, france); - model.addItem(europe, portugal); - model.addItem(europe, spain); + auto america = new TreeItem("America"); + auto asia = new TreeItem("Asia"); + auto europe = new TreeItem("Europe"); + auto oceania = new TreeItem("Oceania"); + + auto brazil = new TreeItem("Brazil"); + auto canada = new TreeItem("Canada"); + auto mexico = new TreeItem("Mexico"); + auto usa = new TreeItem("USA"); + + auto italy = new TreeItem("Italy"); + auto france = new TreeItem("France"); + auto portugal = new TreeItem("Portugal"); + auto spain = new TreeItem("Spain"); + + model.addTopLevelItem(america); + model.addTopLevelItem(asia); + model.addTopLevelItem(europe); + model.addTopLevelItem(oceania); + model.addItem(america, brazil); + model.addItem(america, canada); + model.addItem(america, mexico); + model.addItem(america, usa); + model.addItem(europe, italy); + model.addItem(europe, france); + model.addItem(europe, portugal); + model.addItem(europe, spain); } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) +{ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif - QGuiApplication app(argc, argv); - QQmlApplicationEngine engine; - engine.addImportPath("qrc:/modules"); - - auto treeModel = new TreeModel(&engine); - populateModel(*treeModel); - - engine.rootContext()->setContextProperty("treeModel", treeModel); - const QUrl url(QStringLiteral("qrc:/main.qml")); - QObject::connect( - &engine, &QQmlApplicationEngine::objectCreated, &app, - [url](QObject *obj, const QUrl &objUrl) { - if (!obj && url == objUrl) QCoreApplication::exit(-1); - }, - Qt::QueuedConnection); - engine.load(url); - - return app.exec(); -} + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + engine.addImportPath("qrc:/modules"); + auto treeModel = new TreeModel(&engine); + populateModel(*treeModel); + + engine.rootContext()->setContextProperty("treeModel", treeModel); + const QUrl url(QStringLiteral("qrc:/main.qml")); + QObject::connect( + &engine, + &QQmlApplicationEngine::objectCreated, + &app, + [url](QObject* obj, const QUrl& objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, + Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +} diff --git a/examples/styled/main.cpp b/examples/styled/main.cpp index 062d709..4957605 100644 --- a/examples/styled/main.cpp +++ b/examples/styled/main.cpp @@ -1,61 +1,64 @@ +#include "tree_model.h" + #include #include #include -#include "tree_model.h" - void populateModel(TreeModel& model) { - auto america = new TreeItem("America"); - auto asia = new TreeItem("Asia"); - auto europe = new TreeItem("Europe"); - auto oceania = new TreeItem("Oceania"); - - auto brazil = new TreeItem("Brazil"); - auto canada = new TreeItem("Canada"); - auto mexico = new TreeItem("Mexico"); - auto usa = new TreeItem("USA"); - - auto italy = new TreeItem("Italy"); - auto france = new TreeItem("France"); - auto portugal = new TreeItem("Portugal"); - auto spain = new TreeItem("Spain"); - - model.addTopLevelItem(america); - model.addTopLevelItem(asia); - model.addTopLevelItem(europe); - model.addTopLevelItem(oceania); - model.addItem(america, brazil); - model.addItem(america, canada); - model.addItem(america, mexico); - model.addItem(america, usa); - model.addItem(europe, italy); - model.addItem(europe, france); - model.addItem(europe, portugal); - model.addItem(europe, spain); + auto america = new TreeItem("America"); + auto asia = new TreeItem("Asia"); + auto europe = new TreeItem("Europe"); + auto oceania = new TreeItem("Oceania"); + + auto brazil = new TreeItem("Brazil"); + auto canada = new TreeItem("Canada"); + auto mexico = new TreeItem("Mexico"); + auto usa = new TreeItem("USA"); + + auto italy = new TreeItem("Italy"); + auto france = new TreeItem("France"); + auto portugal = new TreeItem("Portugal"); + auto spain = new TreeItem("Spain"); + + model.addTopLevelItem(america); + model.addTopLevelItem(asia); + model.addTopLevelItem(europe); + model.addTopLevelItem(oceania); + model.addItem(america, brazil); + model.addItem(america, canada); + model.addItem(america, mexico); + model.addItem(america, usa); + model.addItem(europe, italy); + model.addItem(europe, france); + model.addItem(europe, portugal); + model.addItem(europe, spain); } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) +{ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif - QGuiApplication app(argc, argv); - QQmlApplicationEngine engine; - engine.addImportPath("qrc:/modules"); - - auto treeModel = new TreeModel(&engine); - populateModel(*treeModel); - - engine.rootContext()->setContextProperty("treeModel", treeModel); - const QUrl url(QStringLiteral("qrc:/main.qml")); - QObject::connect( - &engine, &QQmlApplicationEngine::objectCreated, &app, - [url](QObject *obj, const QUrl &objUrl) { - if (!obj && url == objUrl) QCoreApplication::exit(-1); - }, - Qt::QueuedConnection); - engine.load(url); - - return app.exec(); -} + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + engine.addImportPath("qrc:/modules"); + auto treeModel = new TreeModel(&engine); + populateModel(*treeModel); + + engine.rootContext()->setContextProperty("treeModel", treeModel); + const QUrl url(QStringLiteral("qrc:/main.qml")); + QObject::connect( + &engine, + &QQmlApplicationEngine::objectCreated, + &app, + [url](QObject* obj, const QUrl& objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, + Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +} diff --git a/modules/QMLTreeView/tree_item.cpp b/modules/QMLTreeView/tree_item.cpp index 948bb28..0297324 100644 --- a/modules/QMLTreeView/tree_item.cpp +++ b/modules/QMLTreeView/tree_item.cpp @@ -22,92 +22,89 @@ * SOFTWARE. */ - #include "tree_item.h" TreeItem::TreeItem() - : _itemData(), - _parentItem(nullptr) -{ -} + : _itemData() + , _parentItem(nullptr) +{} TreeItem::TreeItem(const QVariant& data) - : _itemData(data), - _parentItem(nullptr) -{ -} + : _itemData(data) + , _parentItem(nullptr) +{} TreeItem::~TreeItem() { - qDeleteAll(_childItems); + qDeleteAll(_childItems); } TreeItem* TreeItem::parentItem() { - return _parentItem; + return _parentItem; } void TreeItem::setParentItem(TreeItem* parentItem) { - _parentItem = parentItem; + _parentItem = parentItem; } void TreeItem::appendChild(TreeItem* item) { - if(item && !_childItems.contains(item)){ - _childItems.append(item); - } + if (item && !_childItems.contains(item)) { + _childItems.append(item); + } } void TreeItem::removeChild(TreeItem* item) { - if(item){ - _childItems.removeAll(item); - } + if (item) { + _childItems.removeAll(item); + } } TreeItem* TreeItem::child(int row) { - return _childItems.value(row); + return _childItems.value(row); } int TreeItem::childCount() const { - return _childItems.count(); + return _childItems.count(); } const QVariant& TreeItem::data() const { - return _itemData; + return _itemData; } void TreeItem::setData(const QVariant& data) { - _itemData = data; + _itemData = data; } bool TreeItem::isLeaf() const { - return _childItems.isEmpty(); + return _childItems.isEmpty(); } int TreeItem::depth() const { - int depth = 0; - TreeItem* anchestor = _parentItem; - while(anchestor){ - ++depth; - anchestor = anchestor->parentItem(); - } - - return depth; + int depth = 0; + TreeItem* anchestor = _parentItem; + while (anchestor) { + ++depth; + anchestor = anchestor->parentItem(); + } + + return depth; } int TreeItem::row() const { - if (_parentItem){ - return _parentItem->_childItems.indexOf(const_cast(this)); - } + if (_parentItem) { + return _parentItem->_childItems.indexOf(const_cast(this)); + } - return 0; + return 0; } diff --git a/modules/QMLTreeView/tree_item.h b/modules/QMLTreeView/tree_item.h index b586fbc..c73e080 100644 --- a/modules/QMLTreeView/tree_item.h +++ b/modules/QMLTreeView/tree_item.h @@ -36,48 +36,48 @@ */ class TreeItem { - friend class TreeModel; + friend class TreeModel; public: - //! Create an empty item. - TreeItem(); + //! Create an empty item. + TreeItem(); - //! Create an item with the given data. - explicit TreeItem(const QVariant& data); + //! Create an item with the given data. + explicit TreeItem(const QVariant& data); - //! Destroy the item. It will destroy every child. - ~TreeItem(); + //! Destroy the item. It will destroy every child. + ~TreeItem(); - //! Return the stored data of the node. - const QVariant& data() const; + //! Return the stored data of the node. + const QVariant& data() const; - //! Set the internal data of the node. - void setData(const QVariant& data); + //! Set the internal data of the node. + void setData(const QVariant& data); - //! Return the number of children nodes. - int childCount() const; + //! Return the number of children nodes. + int childCount() const; - int row() const; + int row() const; - //! Return true if the node is a leaf node (no children). - bool isLeaf() const; + //! Return true if the node is a leaf node (no children). + bool isLeaf() const; - //! Return the depth of this node inside the tree. - int depth() const; + //! Return the depth of this node inside the tree. + int depth() const; private: - TreeItem* parentItem(); - void setParentItem(TreeItem* parentItem); + TreeItem* parentItem(); + void setParentItem(TreeItem* parentItem); - void appendChild(TreeItem* item); - void removeChild(TreeItem* item); + void appendChild(TreeItem* item); + void removeChild(TreeItem* item); - TreeItem* child(int row); + TreeItem* child(int row); private: - QVariant _itemData; - TreeItem* _parentItem; - QVector _childItems; + QVariant _itemData; + TreeItem* _parentItem; + QVector _childItems; }; #endif // QML_TREEVIEW_TREE_ITEM_H diff --git a/modules/QMLTreeView/tree_model.cpp b/modules/QMLTreeView/tree_model.cpp index f125442..2ab70ab 100644 --- a/modules/QMLTreeView/tree_model.cpp +++ b/modules/QMLTreeView/tree_model.cpp @@ -22,178 +22,176 @@ * SOFTWARE. */ - #include "tree_model.h" TreeModel::TreeModel(QObject* parent) - : QAbstractItemModel(parent), - _rootItem{new TreeItem()} -{ -} + : QAbstractItemModel(parent) + , _rootItem{new TreeItem()} +{} TreeModel::~TreeModel() { - delete _rootItem; + delete _rootItem; } int TreeModel::rowCount(const QModelIndex& parent) const { - if (!parent.isValid()){ - return _rootItem->childCount(); - } + if (!parent.isValid()) { + return _rootItem->childCount(); + } - return internalPointer(parent)->childCount(); + return internalPointer(parent)->childCount(); } -int TreeModel::columnCount(const QModelIndex& /*parent*/) const +int TreeModel::columnCount(const QModelIndex& /*parent*/) const { - // This is basically flatten as a list model - return 1; + // This is basically flatten as a list model + return 1; } QModelIndex TreeModel::index(const int row, const int column, const QModelIndex& parent) const { - if (!hasIndex(row, column, parent)){ - return {}; - } + if (!hasIndex(row, column, parent)) { + return {}; + } - TreeItem* item = _rootItem; - if (parent.isValid()){ - item = internalPointer(parent); - } + TreeItem* item = _rootItem; + if (parent.isValid()) { + item = internalPointer(parent); + } - if (auto child = item->child(row)){ - return createIndex(row, column, child); - } + if (auto child = item->child(row)) { + return createIndex(row, column, child); + } - return {}; + return {}; } QModelIndex TreeModel::parent(const QModelIndex& index) const { - if (!index.isValid()){ - return {}; - } + if (!index.isValid()) { + return {}; + } - TreeItem* childItem = internalPointer(index); - TreeItem* parentItem = childItem->parentItem(); + TreeItem* childItem = internalPointer(index); + TreeItem* parentItem = childItem->parentItem(); - if (!parentItem){ - return {}; - } + if (!parentItem) { + return {}; + } - if (parentItem == _rootItem){ - return {}; - } + if (parentItem == _rootItem) { + return {}; + } - return createIndex(parentItem->row(), 0, parentItem); + return createIndex(parentItem->row(), 0, parentItem); } QVariant TreeModel::data(const QModelIndex& index, const int role) const { - if (!index.isValid() || role != Qt::DisplayRole) { - return QVariant(); - } + if (!index.isValid() || role != Qt::DisplayRole) { + return QVariant(); + } - return internalPointer(index)->data(); + return internalPointer(index)->data(); } bool TreeModel::setData(const QModelIndex& index, const QVariant& value, int /*role*/) { - if(!index.isValid()){ - return false; - } + if (!index.isValid()) { + return false; + } - if(auto item = internalPointer(index)){ - item->setData(value); - emit dataChanged(index, index, {Qt::EditRole}); - } + if (auto item = internalPointer(index)) { + item->setData(value); + emit dataChanged(index, index, {Qt::EditRole}); + } - return false; + return false; } void TreeModel::addTopLevelItem(TreeItem* child) { - if(child){ - addItem(_rootItem, child); - } + if (child) { + addItem(_rootItem, child); + } } void TreeModel::addItem(TreeItem* parent, TreeItem* child) { - if(!child || !parent){ - return; - } + if (!child || !parent) { + return; + } - emit layoutAboutToBeChanged(); + emit layoutAboutToBeChanged(); - if (child->parentItem()) { - beginRemoveRows(QModelIndex(), child->parentItem()->childCount() - 1, child->parentItem()->childCount()); - child->parentItem()->removeChild(child); - endRemoveRows(); - } + if (child->parentItem()) { + beginRemoveRows(QModelIndex(), child->parentItem()->childCount() - 1, child->parentItem()->childCount()); + child->parentItem()->removeChild(child); + endRemoveRows(); + } - beginInsertRows(QModelIndex(), parent->childCount() - 1, parent->childCount() - 1); - child->setParentItem(parent); - parent->appendChild(child); - endInsertRows(); + beginInsertRows(QModelIndex(), parent->childCount() - 1, parent->childCount() - 1); + child->setParentItem(parent); + parent->appendChild(child); + endInsertRows(); - emit layoutChanged(); + emit layoutChanged(); } void TreeModel::removeItem(TreeItem* item) { - if(!item){ - return; - } + if (!item) { + return; + } - emit layoutAboutToBeChanged(); + emit layoutAboutToBeChanged(); - if (item->parentItem()) { - beginRemoveRows(QModelIndex(), item->parentItem()->childCount() - 1, item->parentItem()->childCount()); - item->parentItem()->removeChild(item); - endRemoveRows(); - } + if (item->parentItem()) { + beginRemoveRows(QModelIndex(), item->parentItem()->childCount() - 1, item->parentItem()->childCount()); + item->parentItem()->removeChild(item); + endRemoveRows(); + } - emit layoutChanged(); + emit layoutChanged(); } TreeItem* TreeModel::rootItem() const { - return _rootItem; + return _rootItem; } QModelIndex TreeModel::rootIndex() { - return {}; + return {}; } int TreeModel::depth(const QModelIndex& index) const { - int count = 0; - auto anchestor = index; - if(!index.isValid()){ - return 0; - } - while(anchestor.parent().isValid()){ - anchestor = anchestor.parent(); - ++count; - } - - return count; + int count = 0; + auto anchestor = index; + if (!index.isValid()) { + return 0; + } + while (anchestor.parent().isValid()) { + anchestor = anchestor.parent(); + ++count; + } + + return count; } void TreeModel::clear() { - emit layoutAboutToBeChanged(); - beginResetModel(); - delete _rootItem; - _rootItem = new TreeItem(); - endResetModel(); - emit layoutChanged(); + emit layoutAboutToBeChanged(); + beginResetModel(); + delete _rootItem; + _rootItem = new TreeItem(); + endResetModel(); + emit layoutChanged(); } TreeItem* TreeModel::internalPointer(const QModelIndex& index) const { - return static_cast(index.internalPointer()); + return static_cast(index.internalPointer()); } diff --git a/modules/QMLTreeView/tree_model.h b/modules/QMLTreeView/tree_model.h index 1a65497..517dec2 100644 --- a/modules/QMLTreeView/tree_model.h +++ b/modules/QMLTreeView/tree_model.h @@ -25,64 +25,64 @@ #ifndef QML_TREEVIEW_TREE_MODEL_H #define QML_TREEVIEW_TREE_MODEL_H -#include - #include "tree_item.h" +#include + /*! * The Tree Model works as List Model, using one column and using the row information * referred to the parent node. */ class TreeModel : public QAbstractItemModel { - Q_OBJECT + Q_OBJECT public: - explicit TreeModel(QObject* parent = nullptr); - ~TreeModel() override; + explicit TreeModel(QObject* parent = nullptr); + ~TreeModel() override; - // Overriden method from QAbstractItemModel + // Overriden method from QAbstractItemModel public: - int rowCount(const QModelIndex& index) const override; - int columnCount(const QModelIndex& index) const override; + int rowCount(const QModelIndex& index) const override; + int columnCount(const QModelIndex& index) const override; - QModelIndex index(int row, int column, const QModelIndex& parent) const override; - QModelIndex parent(const QModelIndex& childIndex) const override; + QModelIndex index(int row, int column, const QModelIndex& parent) const override; + QModelIndex parent(const QModelIndex& childIndex) const override; - QVariant data(const QModelIndex& index, int role = 0) const override; - bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; + QVariant data(const QModelIndex& index, int role = 0) const override; + bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; public: - //! Add an item to the top level. - void addTopLevelItem(TreeItem* child); + //! Add an item to the top level. + void addTopLevelItem(TreeItem* child); - //! Add a child to the parent item. - void addItem(TreeItem* parent, TreeItem* child); + //! Add a child to the parent item. + void addItem(TreeItem* parent, TreeItem* child); - //! Remove the item from the model. - void removeItem(TreeItem* item); + //! Remove the item from the model. + void removeItem(TreeItem* item); - //! Return the root item of the model. - TreeItem* rootItem() const; + //! Return the root item of the model. + TreeItem* rootItem() const; - //! Return the depth for the given index - Q_INVOKABLE int depth(const QModelIndex& index) const; + //! Return the depth for the given index + Q_INVOKABLE int depth(const QModelIndex& index) const; - //! Clear the model. - Q_INVOKABLE void clear(); + //! Clear the model. + Q_INVOKABLE void clear(); - /*! + /*! * Return the root item to the QML Side. * This method is not meant to be used in client code. */ - Q_INVOKABLE QModelIndex rootIndex(); + Q_INVOKABLE QModelIndex rootIndex(); private: - TreeItem* internalPointer(const QModelIndex& index) const; + TreeItem* internalPointer(const QModelIndex& index) const; private: - TreeItem* _rootItem; + TreeItem* _rootItem; }; #endif // QML_TREEVIEW_TREE_MODEL_H From 7f4ed579d44bdd9d45f08ba7d378b2d366abad37 Mon Sep 17 00:00:00 2001 From: Daguerreo Date: Tue, 5 Sep 2023 10:58:05 +0200 Subject: [PATCH 6/8] Fixed compilation for Qt 6 --- modules/QMLTreeView/tree_model.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/QMLTreeView/tree_model.cpp b/modules/QMLTreeView/tree_model.cpp index 2ab70ab..c729645 100644 --- a/modules/QMLTreeView/tree_model.cpp +++ b/modules/QMLTreeView/tree_model.cpp @@ -126,12 +126,12 @@ void TreeModel::addItem(TreeItem* parent, TreeItem* child) emit layoutAboutToBeChanged(); if (child->parentItem()) { - beginRemoveRows(QModelIndex(), child->parentItem()->childCount() - 1, child->parentItem()->childCount()); + beginRemoveRows(QModelIndex(), qMax(parent->childCount() - 1, 0), qMax(parent->childCount(), 0)); child->parentItem()->removeChild(child); endRemoveRows(); } - beginInsertRows(QModelIndex(), parent->childCount() - 1, parent->childCount() - 1); + beginInsertRows(QModelIndex(), qMax(parent->childCount() - 1, 0), qMax(parent->childCount() - 1, 0)); child->setParentItem(parent); parent->appendChild(child); endInsertRows(); @@ -148,7 +148,7 @@ void TreeModel::removeItem(TreeItem* item) emit layoutAboutToBeChanged(); if (item->parentItem()) { - beginRemoveRows(QModelIndex(), item->parentItem()->childCount() - 1, item->parentItem()->childCount()); + beginRemoveRows(QModelIndex(), qMax(item->childCount() - 1, 0), qMax(item->childCount(), 0)); item->parentItem()->removeChild(item); endRemoveRows(); } From cac655e7d1b6a8d2f0ccce4a3b7b5e5bc3c5d035 Mon Sep 17 00:00:00 2001 From: Daguerreo Date: Tue, 5 Sep 2023 11:16:53 +0200 Subject: [PATCH 7/8] Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1cc21c1..b6eab66 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ This project provides a **QML Tree View** with a **C++ Tree Model** for **Qt 5.15** and **QuickControls 2**. -Since **Qt 6.3** [TreeView](https://doc.qt.io/qt-6/qml-qtquick-treeview.html) it's a standard component with easy use, -so refers to that for Qt 6. +Since **Qt 6.3** [TreeView](https://doc.qt.io/qt-6/qml-qtquick-treeview.html) has been added as standard component. +It is suggested to use the standard one. ## Features - QML Tree View From 74046de96f00d2069d947527a652e1f14542bf28 Mon Sep 17 00:00:00 2001 From: Daguerreo Date: Tue, 5 Sep 2023 11:32:52 +0200 Subject: [PATCH 8/8] Added CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..463a99a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# 1.0.1 + +* Fixed bug which caused the plugin to fail for Qt6