diff --git a/resources/qml/RowDelegateChooser.qml b/resources/qml/RowDelegateChooser.qml index b7b6bdf4..bacd970a 100644 --- a/resources/qml/RowDelegateChooser.qml +++ b/resources/qml/RowDelegateChooser.qml @@ -5,7 +5,7 @@ import com.github.nheko 1.0 import "./delegates" DelegateChooser { - role: "type" + //role: "type" //< not supported in our custom implementation, have to use roleValue width: chat.width roleValue: model.type @@ -46,7 +46,6 @@ DelegateChooser { TimelineRow { view: chat; Redacted { id: kid } } } DelegateChoice { - //roleValue: MtxEvent.Redacted TimelineRow { view: chat; Placeholder { id: kid } } } } diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index e09b9ed3..4e379567 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -90,7 +90,15 @@ Rectangle { onMovementEnded: updatePosition() spacing: 4 - delegate: RowDelegateChooser {} + delegate: RowDelegateChooser { + function isFullyVisible() { + return height > 1 && (y - chat.contentY - 1) + height < chat.height + } + function getIndex() { + return index; + } + + } section { property: "section" 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 #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) -#include -#else -#include -#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 *p, DelegateChoice *c) { DelegateChooser *dc = static_cast(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 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 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 choices_; QQuickItem *child;