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 | width: topItem.width | ||||
29 | height: metaDataLabelMetric.height * 1.5 | ||||
30 | | ||||
31 | TextMetrics { | ||||
32 | id: metaDataLabelMetric | ||||
33 | | ||||
34 | text: model.name | ||||
35 | | ||||
36 | font.weight: Font.Bold | ||||
37 | } | ||||
38 | | ||||
39 | Label { | ||||
40 | id: metaDataLabels | ||||
41 | | ||||
42 | text: model.name | ||||
43 | | ||||
44 | font.weight: Font.Bold | ||||
45 | | ||||
46 | horizontalAlignment: Text.AlignLeft | ||||
47 | | ||||
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 | active: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry | ||||
55 | visible: model.type === TrackMetadataModel.TextEntry || model.type === TrackMetadataModel.IntegerEntry | ||||
56 | | ||||
57 | Layout.fillWidth: true | ||||
58 | | ||||
59 | sourceComponent: LabelWithToolTip { | ||||
60 | text: model.display | ||||
61 | | ||||
62 | horizontalAlignment: Text.AlignLeft | ||||
63 | elide: Text.ElideRight | ||||
64 | | ||||
65 | anchors.fill: parent | ||||
66 | } | ||||
67 | } | ||||
68 | | ||||
69 | Loader { | ||||
70 | active: model.type === TrackMetadataModel.DateEntry | ||||
71 | visible: model.type === TrackMetadataModel.DateEntry | ||||
72 | | ||||
73 | Layout.fillWidth: true | ||||
74 | | ||||
75 | sourceComponent: LabelWithToolTip { | ||||
76 | text: rawDate.toLocaleDateString() | ||||
77 | | ||||
78 | horizontalAlignment: Text.AlignLeft | ||||
79 | elide: Text.ElideRight | ||||
80 | | ||||
81 | anchors.fill: parent | ||||
82 | | ||||
83 | property date rawDate: new Date(model.display) | ||||
84 | } | ||||
85 | } | ||||
86 | | ||||
87 | Loader { | ||||
88 | active: model.type === TrackMetadataModel.RatingEntry | ||||
89 | visible: model.type === TrackMetadataModel.RatingEntry | ||||
90 | | ||||
91 | Layout.fillWidth: true | ||||
92 | | ||||
93 | sourceComponent: RatingStar { | ||||
94 | starRating: model.display | ||||
95 | starSize: elisaTheme.ratingStarSize | ||||
96 | | ||||
97 | readOnly: true | ||||
98 | | ||||
99 | anchors { | ||||
100 | left: parent.left | ||||
101 | top: parent.top | ||||
102 | bottom: parent.bottom | ||||
103 | } | ||||
104 | } | ||||
105 | } | ||||
106 | } |