Use a basic implementation of a DelegateChooser for compat with older Qt
The interface is taken from Qt/KDE, but the implementation is different,
because the Qt implementation depends on some Qt internals.
3 files changed, 54 insertions, 45 deletions
diff --git a/resources/qml/RowDelegateChooser.qml b/resources/qml/RowDelegateChooser.qml
new file mode 100644
index 00000000..b7b6bdf4
--- /dev/null
+++ b/resources/qml/RowDelegateChooser.qml
@@ -0,0 +1,52 @@
+import QtQuick 2.6
+import Qt.labs.qmlmodels 1.0
+import com.github.nheko 1.0
+
+import "./delegates"
+
+DelegateChooser {
+ role: "type"
+ width: chat.width
+ roleValue: model.type
+
+ DelegateChoice {
+ roleValue: MtxEvent.TextMessage
+ TimelineRow { view: chat; TextMessage { id: kid } }
+ }
+ DelegateChoice {
+ roleValue: MtxEvent.NoticeMessage
+ TimelineRow { view: chat; NoticeMessage { id: kid } }
+ }
+ DelegateChoice {
+ roleValue: MtxEvent.EmoteMessage
+ TimelineRow { view: chat; TextMessage { id: kid } }
+ }
+ DelegateChoice {
+ roleValue: MtxEvent.ImageMessage
+ TimelineRow { view: chat; ImageMessage { id: kid } }
+ }
+ DelegateChoice {
+ roleValue: MtxEvent.Sticker
+ TimelineRow { view: chat; ImageMessage { id: kid } }
+ }
+ DelegateChoice {
+ roleValue: MtxEvent.FileMessage
+ TimelineRow { view: chat; FileMessage { id: kid } }
+ }
+ DelegateChoice {
+ roleValue: MtxEvent.VideoMessage
+ TimelineRow { view: chat; PlayableMediaMessage { id: kid } }
+ }
+ DelegateChoice {
+ roleValue: MtxEvent.AudioMessage
+ TimelineRow { view: chat; PlayableMediaMessage { id: kid } }
+ }
+ DelegateChoice {
+ roleValue: MtxEvent.Redacted
+ 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 d1ada3ea..e09b9ed3 100644
--- a/resources/qml/TimelineView.qml
+++ b/resources/qml/TimelineView.qml
@@ -3,7 +3,6 @@ import QtQuick.Controls 2.1
import QtQuick.Layouts 1.2
import QtGraphicalEffects 1.0
import QtQuick.Window 2.2
-import Qt.labs.qmlmodels 1.0
import com.github.nheko 1.0
@@ -91,50 +90,7 @@ Rectangle {
onMovementEnded: updatePosition()
spacing: 4
- delegate: DelegateChooser {
- role: "type"
- DelegateChoice {
- roleValue: MtxEvent.TextMessage
- TimelineRow { view: chat; TextMessage { id: kid } }
- }
- DelegateChoice {
- roleValue: MtxEvent.NoticeMessage
- TimelineRow { view: chat; NoticeMessage { id: kid } }
- }
- DelegateChoice {
- roleValue: MtxEvent.EmoteMessage
- TimelineRow { view: chat; TextMessage { id: kid } }
- }
- DelegateChoice {
- roleValue: MtxEvent.ImageMessage
- TimelineRow { view: chat; ImageMessage { id: kid } }
- }
- DelegateChoice {
- roleValue: MtxEvent.Sticker
- TimelineRow { view: chat; ImageMessage { id: kid } }
- }
- DelegateChoice {
- roleValue: MtxEvent.FileMessage
- TimelineRow { view: chat; FileMessage { id: kid } }
- }
- DelegateChoice {
- roleValue: MtxEvent.VideoMessage
- TimelineRow { view: chat; PlayableMediaMessage { id: kid } }
- }
- DelegateChoice {
- roleValue: MtxEvent.AudioMessage
- TimelineRow { view: chat; PlayableMediaMessage { id: kid } }
- }
- DelegateChoice {
- roleValue: MtxEvent.Redacted
- TimelineRow { view: chat; Redacted { id: kid } }
- }
- DelegateChoice {
- //roleValue: MtxEvent.Redacted
- TimelineRow { view: chat; Placeholder { id: kid } }
- }
- }
-
+ delegate: RowDelegateChooser {}
section {
property: "section"
diff --git a/resources/res.qrc b/resources/res.qrc
index 11a20e54..4816ffad 100644
--- a/resources/res.qrc
+++ b/resources/res.qrc
@@ -116,6 +116,7 @@
</qresource>
<qresource prefix="/">
<file>qml/TimelineView.qml</file>
+ <file>qml/RowDelegateChooser.qml</file>
<file>qml/Avatar.qml</file>
<file>qml/StatusIndicator.qml</file>
<file>qml/EncryptionIndicator.qml</file>
|