From 531f659e591402c4b390d0b445744a44368758b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Thu, 11 Apr 2024 15:27:15 +0800 Subject: [PATCH] update --- example/qml/page/T_OpenGL.qml | 8 +------- example/src/component/OpenGLItem.cpp | 2 +- example/src/component/OpenGLItem.h | 4 ++-- src/FluTreeModel.h | 29 ++++++++++++++++------------ 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/example/qml/page/T_OpenGL.qml b/example/qml/page/T_OpenGL.qml index 8582fb3e..c39b4869 100644 --- a/example/qml/page/T_OpenGL.qml +++ b/example/qml/page/T_OpenGL.qml @@ -10,13 +10,10 @@ FluContentPage{ title: qsTr("OpenGL") - FluFrame{ anchors.fill: parent - OpenGLItem{ - width: 320 - height: 480 + anchors.fill: parent SequentialAnimation on t { NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad } NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad } @@ -24,9 +21,6 @@ FluContentPage{ running: true } } - } - - } diff --git a/example/src/component/OpenGLItem.cpp b/example/src/component/OpenGLItem.cpp index 60c6bdee..58e86d78 100644 --- a/example/src/component/OpenGLItem.cpp +++ b/example/src/component/OpenGLItem.cpp @@ -47,7 +47,7 @@ QOpenGLFramebufferObject *FBORenderer::createFramebufferObject(const QSize &size } void FBORenderer::render() { - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glEnable(GL_DEPTH_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); program.bind(); diff --git a/example/src/component/OpenGLItem.h b/example/src/component/OpenGLItem.h index 4b9da909..d1570c7f 100644 --- a/example/src/component/OpenGLItem.h +++ b/example/src/component/OpenGLItem.h @@ -12,11 +12,11 @@ Q_OBJECT public: explicit OpenGLItem(QQuickItem *parent = nullptr); - QQuickFramebufferObject::Renderer *createRenderer() const override; + [[nodiscard]] QQuickFramebufferObject::Renderer *createRenderer() const override; void timerEvent(QTimerEvent *) override; - qreal t() const { return m_t; } + [[nodiscard]] qreal t() const { return m_t; } void setT(qreal t); diff --git a/src/FluTreeModel.h b/src/FluTreeModel.h index 7765a66f..07eb6ed6 100644 --- a/src/FluTreeModel.h +++ b/src/FluTreeModel.h @@ -19,10 +19,14 @@ Q_OBJECT public: explicit FluTreeNode(QObject *parent = nullptr); - Q_INVOKABLE int depth() const { return _depth; }; - Q_INVOKABLE bool isExpanded() const { return _isExpanded; }; - Q_INVOKABLE QVariantMap data() const { return _data; }; - Q_INVOKABLE bool hasChildren() const { return !_children.isEmpty(); }; + [[nodiscard]] Q_INVOKABLE int depth() const { return _depth; }; + + [[nodiscard]] Q_INVOKABLE bool isExpanded() const { return _isExpanded; }; + + [[nodiscard]] Q_INVOKABLE QVariantMap data() const { return _data; }; + + [[nodiscard]] Q_INVOKABLE bool hasChildren() const { return !_children.isEmpty(); }; + Q_INVOKABLE bool hasNextNodeByIndex(int index) { FluTreeNode *p = this; for (int i = 0; i <= _depth - index - 1; i++) { @@ -34,7 +38,7 @@ public: return true; } - Q_INVOKABLE bool checked() const { + [[nodiscard]] Q_INVOKABLE bool checked() const { if (!hasChildren()) { return _checked; } @@ -46,6 +50,7 @@ public: } return true; }; + Q_INVOKABLE bool hideLineFooter() { if (_parent) { auto childIndex = _parent->_children.indexOf(this); @@ -60,7 +65,7 @@ public: return false; }; - bool isShown() const { + [[nodiscard]] bool isShown() const { auto p = _parent; while (p) { if (!p->_isExpanded) { @@ -96,17 +101,17 @@ public: explicit FluTreeModel(QObject *parent = nullptr); - int rowCount(const QModelIndex &parent = {}) const override; + [[nodiscard]] int rowCount(const QModelIndex &parent = {}) const override; - int columnCount(const QModelIndex &parent = {}) const override; + [[nodiscard]] int columnCount(const QModelIndex &parent = {}) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - QHash roleNames() const override; + [[nodiscard]] QHash roleNames() const override; - QModelIndex parent(const QModelIndex &child) const override; + [[nodiscard]] QModelIndex parent(const QModelIndex &child) const override; - QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override; + [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override; Q_INVOKABLE void removeRows(int row, int count);