Changeset View
Changeset View
Standalone View
Standalone View
src/qml/MetaDataDelegate.qml
Show All 19 Lines | |||||
20 | import QtQuick.Layouts 1.2 | 20 | import QtQuick.Layouts 1.2 | ||
21 | 21 | | |||
22 | import org.kde.elisa 1.0 | 22 | import org.kde.elisa 1.0 | ||
23 | 23 | | |||
24 | RowLayout { | 24 | RowLayout { | ||
25 | id: delegateRow | 25 | id: delegateRow | ||
26 | spacing: 0 | 26 | spacing: 0 | ||
27 | 27 | | |||
28 | height: (model.type === TrackMetadataModel.LongTextEntry ? longTextDisplayLoader.height : (metaDataLabelMetric.boundingRect.height + elisaTheme.layoutVerticalMargin / 2)) | 28 | property bool radio: false | ||
29 | | ||||
30 | height: { | ||||
31 | if(!delegateRow.radio){ | ||||
astippich: codeStyle | |||||
32 | return (model.type === TrackMetadataModel.LongTextEntry ? longTextDisplayLoader.height : (metaDataLabelMetric.boundingRect.height + elisaTheme.layoutVerticalMargin / 2)) | ||||
33 | } | ||||
34 | } | ||||
29 | 35 | | |||
30 | 36 | | |||
37 | signal radioEdited() | ||||
38 | | ||||
31 | TextMetrics { | 39 | TextMetrics { | ||
32 | id: metaDataLabelMetric | 40 | id: metaDataLabelMetric | ||
33 | 41 | | |||
34 | text: 'Metadata Name' | 42 | text: 'Metadata Name' | ||
35 | } | 43 | } | ||
36 | 44 | | |||
37 | Label { | 45 | Label { | ||
38 | id: metaDataLabels | 46 | id: metaDataLabels | ||
39 | 47 | | |||
40 | text: i18nc("Label for a piece of metadata, e.g. 'Album Artist:'", "%1:", model.name) | 48 | text: { | ||
49 | if(model.name !== undefined){ | ||||
astippich: codeStyle | |||||
50 | return i18nc("Label for a piece of metadata, e.g. 'Album Artist:'", "%1:", model.name) | ||||
51 | } | ||||
52 | return "" | ||||
53 | } | ||||
41 | 54 | | |||
42 | font.weight: Font.Bold | 55 | font.weight: Font.Bold | ||
43 | 56 | | |||
44 | horizontalAlignment: Text.AlignRight | 57 | horizontalAlignment: Text.AlignRight | ||
45 | 58 | | |||
46 | Layout.alignment: Qt.AlignTop | 59 | Layout.alignment: Qt.AlignTop | ||
47 | Layout.preferredWidth: 0.8 * elisaTheme.coverImageSize | 60 | Layout.preferredWidth: 0.8 * elisaTheme.coverImageSize | ||
48 | Layout.rightMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin / 2 : 0 | 61 | Layout.rightMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin / 2 : 0 | ||
49 | Layout.leftMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin / 2 : 0 | 62 | Layout.leftMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin / 2 : 0 | ||
50 | } | 63 | } | ||
51 | 64 | | |||
52 | Loader { | 65 | Loader { | ||
53 | id: textDisplayLoader | 66 | id: textDisplayLoader | ||
54 | 67 | | |||
55 | active: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry | 68 | active: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry | ||
56 | visible: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry | 69 | visible: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry | ||
57 | 70 | | |||
58 | Layout.fillWidth: true | 71 | Layout.fillWidth: true | ||
59 | Layout.alignment: Qt.AlignTop | 72 | Layout.alignment: Qt.AlignTop | ||
60 | 73 | | |||
61 | sourceComponent: LabelWithToolTip { | 74 | Component{ | ||
75 | id: labelText | ||||
76 | | ||||
77 | LabelWithToolTip { | ||||
62 | text: model.display | 78 | text: model.display | ||
63 | 79 | | |||
64 | horizontalAlignment: Text.AlignLeft | 80 | horizontalAlignment: Text.AlignLeft | ||
65 | elide: Text.ElideRight | 81 | elide: Text.ElideRight | ||
66 | 82 | | |||
67 | anchors.fill: parent | 83 | anchors.fill: parent | ||
68 | } | 84 | } | ||
69 | } | 85 | } | ||
70 | 86 | | |||
87 | Component{ | ||||
88 | id: fieldText | ||||
89 | | ||||
90 | TextField { | ||||
91 | text: model.display | ||||
92 | | ||||
93 | horizontalAlignment: Text.AlignLeft | ||||
94 | | ||||
95 | anchors.fill: parent | ||||
96 | | ||||
97 | onEditingFinished: { | ||||
98 | if(model.display !== text){ | ||||
99 | model.display = text | ||||
100 | delegateRow.radioEdited() | ||||
101 | } | ||||
102 | } | ||||
103 | } | ||||
104 | } | ||||
105 | | ||||
106 | sourceComponent: (radio ? fieldText : labelText) | ||||
107 | } | ||||
I think there is not a lot that can be shared here. A new delegate is imho suitable in this case. Maybe something like a EditableMetaDataDelegate? We may actually use this one then in the future, too, once Elisa supports metadata editing. astippich: I think there is not a lot that can be shared here. A new delegate is imho suitable in this… | |||||
108 | | ||||
71 | Loader { | 109 | Loader { | ||
72 | id: longTextDisplayLoader | 110 | id: longTextDisplayLoader | ||
73 | 111 | | |||
74 | active: model.type === TrackMetadataModel.LongTextEntry | 112 | active: model.type === TrackMetadataModel.LongTextEntry | ||
75 | visible: model.type === TrackMetadataModel.LongTextEntry | 113 | visible: model.type === TrackMetadataModel.LongTextEntry | ||
76 | 114 | | |||
77 | Layout.fillWidth: true | 115 | Layout.fillWidth: true | ||
78 | Layout.maximumWidth: delegateRow.width - (0.8 * elisaTheme.coverImageSize + elisaTheme.layoutHorizontalMargin * 2) | 116 | Layout.maximumWidth: delegateRow.width - (0.8 * elisaTheme.coverImageSize + elisaTheme.layoutHorizontalMargin * 2) | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |
codeStyle