summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2019-10-25 11:46:25 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2019-11-23 20:06:15 +0100
commitc8f97216faa74b9d3f1f92af7acc509dbe6b5647 (patch)
treeaa9e68c03bc79800cb108bbb19654a75d7634d80 /src
parentUse a basic implementation of a DelegateChooser for compat with older Qt (diff)
downloadnheko-c8f97216faa74b9d3f1f92af7acc509dbe6b5647.tar.xz
Small fixes to delegate chooser implementation
Diffstat (limited to 'src')
-rw-r--r--src/timeline2/DelegateChooser.cpp40
-rw-r--r--src/timeline2/DelegateChooser.h7
2 files changed, 0 insertions, 47 deletions
diff --git a/src/timeline2/DelegateChooser.cpp b/src/timeline2/DelegateChooser.cpp
index ddde93e1..b86fc6cc 100644
--- a/src/timeline2/DelegateChooser.cpp
+++ b/src/timeline2/DelegateChooser.cpp
@@ -5,11 +5,6 @@
 // uses private API, which moved between versions
 #include <QQmlEngine>
 #include <QtGlobal>
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
-#include <QtQmlModels/private/qqmladaptormodel_p.h>
-#else
-#include <QtQml/private/qqmladaptormodel_p.h>
-#endif
 
 QQmlComponent *
 DelegateChoice::delegate() const
@@ -70,44 +65,11 @@ DelegateChooser::choices()
                                                 &DelegateChooser::clearChoices);
 }
 
-QString
-DelegateChooser::role() const
-{
-        return role_;
-}
-
-void
-DelegateChooser::setRole(const QString &role)
-{
-        if (role != role_) {
-                role_ = role;
-                emit roleChanged();
-        }
-}
-
-QQmlComponent *
-DelegateChooser::delegate(QQmlAdaptorModel *adaptorModel, int row, int column) const
-{
-        auto value = adaptorModel->value(adaptorModel->indexAt(row, column), role_);
-
-        for (const auto choice : choices_) {
-                auto choiceValue = choice->roleValue();
-                if (!value.isValid() || choiceValue == value) {
-                        nhlog::ui()->debug("Returned delegate for {}", role_.toStdString());
-                        return choice->delegate();
-                }
-        }
-
-        nhlog::ui()->debug("Returned null delegate");
-        return nullptr;
-}
-
 void
 DelegateChooser::appendChoice(QQmlListProperty<DelegateChoice> *p, DelegateChoice *c)
 {
         DelegateChooser *dc = static_cast<DelegateChooser *>(p->object);
         dc->choices_.append(c);
-        // dc->recalcChild();
 }
 
 int
@@ -132,8 +94,6 @@ DelegateChooser::recalcChild()
         for (const auto choice : choices_) {
                 auto choiceValue = choice->roleValue();
                 if (!roleValue_.isValid() || !choiceValue.isValid() || choiceValue == roleValue_) {
-                        nhlog::ui()->debug("Returned delegate for {}", role_.toStdString());
-
                         if (child) {
                                 // delete child;
                                 child = nullptr;
diff --git a/src/timeline2/DelegateChooser.h b/src/timeline2/DelegateChooser.h
index d2a1cf59..7350e0d3 100644
--- a/src/timeline2/DelegateChooser.h
+++ b/src/timeline2/DelegateChooser.h
@@ -44,19 +44,13 @@ class DelegateChooser : public QQuickItem
 
 public:
         Q_PROPERTY(QQmlListProperty<DelegateChoice> choices READ choices CONSTANT)
-        Q_PROPERTY(QString role READ role WRITE setRole NOTIFY roleChanged)
         Q_PROPERTY(QVariant roleValue READ roleValue WRITE setRoleValue NOTIFY roleValueChanged)
 
         QQmlListProperty<DelegateChoice> choices();
 
-        QString role() const;
-        void setRole(const QString &role);
-
         QVariant roleValue() const;
         void setRoleValue(const QVariant &value);
 
-        QQmlComponent *delegate(QQmlAdaptorModel *adaptorModel, int row, int column = 0) const;
-
         void recalcChild();
         void componentComplete() override;
 
@@ -65,7 +59,6 @@ signals:
         void roleValueChanged();
 
 private:
-        QString role_;
         QVariant roleValue_;
         QList<DelegateChoice *> choices_;
         QQuickItem *child;