[vlc-devel] [PATCH 04/14] qml: use dynamic Columns on KeyNavigableTableView
Abel Tesfaye
abeltesfaye45 at gmail.com
Tue Aug 6 11:18:38 CEST 2019
From: Abel Tesfaye <Abeltesfaye45 at gmail.com>
---
.../qt/qml/utils/KeyNavigableTableView.qml | 59 ++++++++++++-------
1 file changed, 39 insertions(+), 20 deletions(-)
diff --git a/modules/gui/qt/qml/utils/KeyNavigableTableView.qml b/modules/gui/qt/qml/utils/KeyNavigableTableView.qml
index 53832cbe58..255b17353f 100644
--- a/modules/gui/qt/qml/utils/KeyNavigableTableView.qml
+++ b/modules/gui/qt/qml/utils/KeyNavigableTableView.qml
@@ -19,10 +19,10 @@ import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQml.Models 2.2
import QtQuick.Layouts 1.3
-
-import org.videolan.medialib 0.1
+import QtGraphicalEffects 1.0
import "qrc:///utils/" as Utils
+import "qrc:///mediacenter/" as MC
import "qrc:///style/"
NavigableFocusScope {
@@ -30,8 +30,11 @@ NavigableFocusScope {
//forwarded from subview
signal actionForSelection( var selection )
+ signal contextMenuButtonClicked(Item menuParent, var menuModel)
+ signal rightClick(Item menuParent, var menuModel)
property var sortModel: ListModel { }
+ property Component colDelegate: Item { }
property var model: []
property alias contentHeight: view.contentHeight
@@ -47,6 +50,8 @@ NavigableFocusScope {
property color headerColor
property alias delegateModel: delegateModel
+ property real rowHeight: VLCStyle.fontHeight_normal + VLCStyle.margin_large
+ property alias spacing: view.spacing
Utils.SelectableDelegateModel {
id: delegateModel
@@ -61,24 +66,44 @@ NavigableFocusScope {
Package.name: "list"
id: lineView
- width: view.width
- height: VLCStyle.fontHeight_normal + VLCStyle.margin_large
-
- color: VLCStyle.colors.getBgColor(element.DelegateModel.inSelected, hoverArea.containsMouse, this.activeFocus)
+ width: root.width
+ height: root.rowHeight
+ color: VLCStyle.colors.bg
MouseArea {
id: hoverArea
anchors.fill: parent
hoverEnabled: true
+ Keys.onMenuPressed: root.contextMenuButtonClicked(contextButton,rowModel)
+ acceptedButtons: Qt.RightButton | Qt.LeftButton
+
onClicked: {
delegateModel.updateSelection( mouse.modifiers , view.currentIndex, index)
view.currentIndex = rowModel.index
lineView.forceActiveFocus()
+
+ if (mouse.button === Qt.RightButton){
+ root.rightClick(lineView,rowModel)
+ }
}
onDoubleClicked: {
actionForSelection(delegateModel.selectedGroup)
}
+ RectangularGlow {
+ visible: element.DelegateModel.inSelected || hoverArea.containsMouse
+ anchors.fill: parent
+ glowRadius: VLCStyle.margin_xxsmall
+ color: VLCStyle.colors.getBgColor(element.DelegateModel.inSelected, hoverArea.containsMouse, lineView.activeFocus)
+ }
+
+ Rectangle{
+ anchors.fill: parent
+ anchors.topMargin: VLCStyle.margin_xxsmall
+ anchors.bottomMargin: VLCStyle.margin_xxsmall
+ anchors.leftMargin: VLCStyle.margin_xxxsmall
+ anchors.rightMargin: VLCStyle.margin_xxxsmall
+ color: VLCStyle.colors.bg
Row {
anchors {
@@ -86,7 +111,6 @@ NavigableFocusScope {
leftMargin: VLCStyle.margin_normal
rightMargin: VLCStyle.margin_normal
}
-
Repeater {
model: sortModel
@@ -94,23 +118,18 @@ NavigableFocusScope {
height: parent.height
width: model.width * view.width
Layout.alignment: Qt.AlignVCenter
+ Loader{
+ anchors.fill: parent
+ sourceComponent: colDelegate
- Text {
- text: rowModel[model.criteria]
- elide: Text.ElideRight
- font.pixelSize: VLCStyle.fontSize_normal
- color: VLCStyle.colors.text
+ property var rowModel: element.rowModel
+ property var colModel: model
- anchors {
- fill: parent
- leftMargin: VLCStyle.margin_xsmall
- rightMargin: VLCStyle.margin_xsmall
}
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignLeft
- }
+
}
}
+ }
}
}
}
@@ -154,7 +173,7 @@ NavigableFocusScope {
//Layout.alignment: Qt.AlignVCenter
Text {
- text: model.text
+ text: model.text || ""
elide: Text.ElideRight
font {
pixelSize: VLCStyle.fontSize_normal
--
2.21.0
More information about the vlc-devel
mailing list