Changeset View
Changeset View
Standalone View
Standalone View
src/qml/ListBrowserView.qml
- This file was moved from src/qml/MediaAllTracksView.qml.
Show All 21 Lines | |||||
22 | import QtQuick.Window 2.2 | 22 | import QtQuick.Window 2.2 | ||
23 | import QtQml.Models 2.2 | 23 | import QtQml.Models 2.2 | ||
24 | import QtQuick.Layouts 1.2 | 24 | import QtQuick.Layouts 1.2 | ||
25 | import QtGraphicalEffects 1.0 | 25 | import QtGraphicalEffects 1.0 | ||
26 | 26 | | |||
27 | import org.kde.elisa 1.0 | 27 | import org.kde.elisa 1.0 | ||
28 | 28 | | |||
29 | FocusScope { | 29 | FocusScope { | ||
30 | id: rootElement | 30 | id: listView | ||
31 | 31 | | |||
32 | property var stackView | 32 | property bool isSubPage: false | ||
33 | property alias mainTitle: navigationBar.mainTitle | ||||
34 | property alias secondaryTitle: navigationBar.secondaryTitle | ||||
mgallien: Could you use an alias property ? | |||||
35 | property alias image: navigationBar.image | ||||
36 | property alias delegate: contentDirectoryView.delegate | ||||
33 | property alias contentModel: contentDirectoryView.model | 37 | property alias contentModel: contentDirectoryView.model | ||
34 | property alias expandedFilterView: navigationBar.expandedFilterView | 38 | property alias expandedFilterView: navigationBar.expandedFilterView | ||
39 | property alias showRating: navigationBar.showRating | ||||
40 | property alias allowArtistNavigation: navigationBar.allowArtistNavigation | ||||
41 | property var delegateWidth: scrollBar.visible ? contentDirectoryView.width - scrollBar.width : contentDirectoryView.width | ||||
35 | 42 | | |||
43 | signal goBack() | ||||
44 | signal showArtist(var name) | ||||
36 | signal filterViewChanged(bool expandedFilterView) | 45 | signal filterViewChanged(bool expandedFilterView) | ||
37 | 46 | | |||
38 | SystemPalette { | 47 | SystemPalette { | ||
39 | id: myPalette | 48 | id: myPalette | ||
40 | colorGroup: SystemPalette.Active | 49 | colorGroup: SystemPalette.Active | ||
41 | } | 50 | } | ||
42 | 51 | | |||
43 | Theme { | 52 | Theme { | ||
44 | id: elisaTheme | 53 | id: elisaTheme | ||
45 | } | 54 | } | ||
46 | 55 | | |||
47 | ColumnLayout { | 56 | ColumnLayout { | ||
48 | anchors.fill: parent | 57 | anchors.fill: parent | ||
49 | spacing: 0 | 58 | spacing: 0 | ||
50 | 59 | | |||
51 | NavigationActionBar { | 60 | NavigationActionBar { | ||
52 | id: navigationBar | 61 | id: navigationBar | ||
53 | 62 | | |||
54 | mainTitle: i18nc("Title of the view of all tracks", "Tracks") | 63 | mainTitle: listView.mainTitle | ||
55 | secondaryTitle: "" | 64 | secondaryTitle: listView.secondaryTitle | ||
56 | image: elisaTheme.tracksIcon | 65 | image: listView.image | ||
57 | enableGoBack: false | 66 | enableGoBack: isSubPage | ||
58 | 67 | | |||
59 | height: elisaTheme.navigationBarHeight | 68 | height: elisaTheme.navigationBarHeight | ||
60 | Layout.preferredHeight: height | 69 | Layout.preferredHeight: height | ||
61 | Layout.minimumHeight: height | 70 | Layout.minimumHeight: height | ||
62 | Layout.maximumHeight: height | 71 | Layout.maximumHeight: height | ||
63 | Layout.fillWidth: true | 72 | Layout.fillWidth: true | ||
64 | 73 | | |||
65 | Binding { | 74 | Binding { | ||
66 | target: contentModel | 75 | target: contentModel | ||
67 | property: 'filterText' | 76 | property: 'filterText' | ||
68 | value: navigationBar.filterText | 77 | value: navigationBar.filterText | ||
69 | } | 78 | } | ||
70 | 79 | | |||
71 | Binding { | 80 | Binding { | ||
72 | target: contentModel | 81 | target: contentModel | ||
73 | property: 'filterRating' | 82 | property: 'filterRating' | ||
74 | value: navigationBar.filterRating | 83 | value: navigationBar.filterRating | ||
75 | } | 84 | } | ||
76 | 85 | | |||
77 | onEnqueue: contentModel.enqueueToPlayList() | 86 | onEnqueue: contentModel.enqueueToPlayList() | ||
78 | 87 | | |||
79 | onFilterViewChanged: rootElement.filterViewChanged(expandedFilterView) | 88 | onFilterViewChanged: listView.filterViewChanged(expandedFilterView) | ||
80 | 89 | | |||
81 | onReplaceAndPlay: contentModel.replaceAndPlayOfPlayList() | 90 | onReplaceAndPlay: contentModel.replaceAndPlayOfPlayList() | ||
91 | | ||||
92 | onGoBack: listView.goBack() | ||||
93 | | ||||
94 | onShowArtist: listView.showArtist(listView.contentModel.sourceModel.author) | ||||
82 | } | 95 | } | ||
83 | 96 | | |||
84 | Rectangle { | 97 | Rectangle { | ||
85 | color: myPalette.base | 98 | color: myPalette.base | ||
86 | 99 | | |||
87 | Layout.fillHeight: true | 100 | Layout.fillHeight: true | ||
88 | Layout.fillWidth: true | 101 | Layout.fillWidth: true | ||
89 | 102 | | |||
90 | ListView { | 103 | ListView { | ||
91 | id: contentDirectoryView | 104 | id: contentDirectoryView | ||
92 | anchors.topMargin: 20 | 105 | anchors.topMargin: 20 | ||
93 | anchors.fill: parent | 106 | anchors.fill: parent | ||
94 | 107 | | |||
95 | focus: true | 108 | focus: true | ||
96 | 109 | | |||
97 | ScrollBar.vertical: ScrollBar { | 110 | ScrollBar.vertical: ScrollBar { | ||
98 | id: scrollBar | 111 | id: scrollBar | ||
99 | } | 112 | } | ||
100 | boundsBehavior: Flickable.StopAtBounds | 113 | boundsBehavior: Flickable.StopAtBounds | ||
101 | clip: true | 114 | clip: true | ||
102 | | ||||
103 | delegate: MediaTrackDelegate { | | |||
104 | id: entry | | |||
105 | | ||||
106 | width: scrollBar.visible ? contentDirectoryView.width - scrollBar.width : contentDirectoryView.width | | |||
107 | height: elisaTheme.trackDelegateHeight | | |||
108 | | ||||
109 | focus: true | | |||
110 | | ||||
111 | trackData: model.containerData | | |||
112 | | ||||
113 | isFirstTrackOfDisc: false | | |||
114 | | ||||
115 | isSingleDiscAlbum: model.isSingleDiscAlbum | | |||
116 | | ||||
117 | onEnqueue: elisa.mediaPlayList.enqueue(data) | | |||
118 | | ||||
119 | onReplaceAndPlay: elisa.mediaPlayList.replaceAndPlay(data) | | |||
120 | | ||||
121 | onClicked: contentDirectoryView.currentIndex = index | | |||
122 | } | | |||
123 | } | 115 | } | ||
124 | } | 116 | } | ||
125 | } | 117 | } | ||
126 | } | 118 | } | ||
127 | 119 | | |||
This is probably not good for performance. Why do you still define the delegate inside the ListBrowserView component instead of setting the delegate at the places where you instantiate the ListBrowserView component. mgallien: This is probably not good for performance. Why do you still define the delegate inside the… | |||||
That's what I first tried, but the delegates need to know about some properties, for example the width of the listview, which are not available when defined outside. Do you have any ideas how to solve this? astippich: That's what I first tried, but the delegates need to know about some properties, for example… | |||||
You can create alias properties in ListBrowserView to expose the properties of the ListView child. This way, you should be able to move out the delegate (and reduce the size of this file). This way, ListBrowserView can have somehow the same interface than ListView. mgallien: You can create alias properties in ListBrowserView to expose the properties of the ListView… |
Could you use an alias property ?