Changeset View
Changeset View
Standalone View
Standalone View
src/qml/MetaDataDelegate.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2016 Matthieu Gallien <matthieu_gallien@yahoo.fr> | ||||
3 | * | ||||
4 | * This program is free software: you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Lesser General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 3 of the License, or (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | * Lesser General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Lesser General Public License | ||||
15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||
16 | */ | ||||
17 | | ||||
18 | import QtQuick 2.10 | ||||
19 | import QtQuick.Controls 2.2 | ||||
20 | import QtQuick.Layouts 1.2 | ||||
21 | | ||||
22 | import org.kde.elisa 1.0 | ||||
23 | | ||||
24 | RowLayout { | ||||
25 | id: delegateRow | ||||
26 | spacing: 0 | ||||
27 | | ||||
28 | height: (model.type === TrackMetadataModel.LongTextEntry ? longTextDisplayLoader.height : metaDataLabelMetric.height) + (elisaTheme.layoutVerticalMargin / 2) | ||||
29 | | ||||
30 | TextMetrics { | ||||
31 | id: metaDataLabelMetric | ||||
32 | | ||||
33 | text: 'Metadata Name' | ||||
34 | | ||||
35 | font.weight: Font.Bold | ||||
36 | } | ||||
37 | | ||||
38 | Label { | ||||
39 | id: metaDataLabels | ||||
40 | | ||||
41 | text: model.name | ||||
42 | | ||||
43 | font.weight: Font.Bold | ||||
44 | | ||||
45 | horizontalAlignment: Text.AlignLeft | ||||
46 | | ||||
47 | Layout.alignment: Qt.AlignTop | ||||
48 | Layout.preferredWidth: 0.8 * elisaTheme.coverImageSize | ||||
49 | Layout.rightMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin * 2 : 0 | ||||
50 | Layout.leftMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin * 2 : 0 | ||||
51 | } | ||||
52 | | ||||
53 | Loader { | ||||
54 | id: textDisplayLoader | ||||
55 | | ||||
56 | active: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry | ||||
57 | visible: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry | ||||
58 | | ||||
59 | Layout.fillWidth: true | ||||
60 | Layout.alignment: Qt.AlignTop | ||||
61 | | ||||
62 | sourceComponent: LabelWithToolTip { | ||||
63 | text: model.display | ||||
64 | | ||||
65 | horizontalAlignment: Text.AlignLeft | ||||
66 | elide: Text.ElideRight | ||||
67 | | ||||
68 | anchors.fill: parent | ||||
69 | } | ||||
70 | } | ||||
71 | | ||||
72 | Loader { | ||||
73 | id: longTextDisplayLoader | ||||
74 | | ||||
75 | active: model.type === TrackMetadataModel.LongTextEntry | ||||
76 | visible: model.type === TrackMetadataModel.LongTextEntry | ||||
77 | | ||||
78 | Layout.fillWidth: true | ||||
79 | Layout.maximumWidth: delegateRow.width - (0.8 * elisaTheme.coverImageSize + elisaTheme.layoutHorizontalMargin * 2) | ||||
80 | Layout.alignment: Qt.AlignTop | ||||
81 | | ||||
82 | sourceComponent: Label { | ||||
83 | text: model.display | ||||
84 | | ||||
85 | horizontalAlignment: Text.AlignLeft | ||||
86 | elide: Text.ElideRight | ||||
87 | | ||||
88 | anchors.fill: parent | ||||
89 | | ||||
90 | wrapMode: Text.WordWrap | ||||
91 | } | ||||
92 | } | ||||
93 | | ||||
94 | Loader { | ||||
95 | active: model.type === TrackMetadataModel.DateEntry | ||||
96 | visible: model.type === TrackMetadataModel.DateEntry | ||||
97 | | ||||
98 | Layout.fillWidth: true | ||||
99 | Layout.alignment: Qt.AlignTop | ||||
100 | | ||||
101 | sourceComponent: LabelWithToolTip { | ||||
102 | text: rawDate.toLocaleDateString() | ||||
103 | | ||||
104 | horizontalAlignment: Text.AlignLeft | ||||
105 | elide: Text.ElideRight | ||||
106 | | ||||
107 | anchors.fill: parent | ||||
108 | | ||||
109 | property date rawDate: new Date(model.display) | ||||
110 | } | ||||
111 | } | ||||
112 | | ||||
113 | Loader { | ||||
114 | active: model.type === TrackMetadataModel.RatingEntry | ||||
115 | visible: model.type === TrackMetadataModel.RatingEntry | ||||
116 | | ||||
117 | Layout.fillWidth: true | ||||
118 | Layout.alignment: Qt.AlignTop | ||||
119 | | ||||
120 | sourceComponent: RatingStar { | ||||
121 | starRating: model.display | ||||
122 | starSize: elisaTheme.ratingStarSize | ||||
123 | | ||||
124 | readOnly: true | ||||
125 | | ||||
126 | anchors { | ||||
127 | left: parent.left | ||||
128 | top: parent.top | ||||
129 | bottom: parent.bottom | ||||
130 | } | ||||
131 | } | ||||
132 | } | ||||
133 | } |