qt: playlist: use item title if available
[vlc.git] / modules / gui / qt / medialibrary / qml / VideoDisplay.qml
blob014564c7e7129231dcd8852efff807c5240cea9c
1 /*****************************************************************************
2  * Copyright (C) 2019 VLC authors and VideoLAN
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * ( 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
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17  *****************************************************************************/
19 import QtQuick          2.11
20 import QtQuick.Controls 2.4
21 import QtQuick.Layouts  1.3
22 import QtQml.Models     2.2
24 import org.videolan.medialib 0.1
26 import "qrc:///widgets/" as Widgets
27 import "qrc:///style/"
29 Widgets.PageLoader {
30     id: root
32     //---------------------------------------------------------------------------------------------
33     // Properties
34     //---------------------------------------------------------------------------------------------
36     property bool isViewMultiView: true
38     property var contentModel
39     property var sortModel
41     property var tabModel: ListModel {
42         Component.onCompleted: {
43             pageModel.forEach(function(e) {
44                 append({
45                     name       : e.name,
46                     displayText: e.displayText
47                 })
48             })
49         }
50     }
52     property Component localMenuDelegate: Widgets.LocalTabBar {
53         currentView: root.view
55         model: tabModel
57         onClicked: root.loadIndex(index)
58     }
60     //---------------------------------------------------------------------------------------------
61     // Settings
62     //---------------------------------------------------------------------------------------------
64     defaultPage: "all"
66     pageModel: [{
67             name: "all",
68             displayText: i18n.qtr("All"),
69             url: "qrc:///medialibrary/VideoAllDisplay.qml"
70         },{
71             name: "groups",
72             displayText: i18n.qtr("Groups"),
73             url: "qrc:///medialibrary/VideoGroupsDisplay.qml"
74         },{
75             name: "playlists",
76             displayText: i18n.qtr("Playlists"),
77             url: "qrc:///medialibrary/VideoPlaylistsDisplay.qml"
78         }
79     ]
81     onCurrentItemChanged: {
82         isViewMultiView = (currentItem.isViewMultiView === undefined
83                            ||
84                            currentItem.isViewMultiView);
86         contentModel = currentItem.model;
87         sortModel    = currentItem.sortModel;
88     }
90     //---------------------------------------------------------------------------------------------
91     // Functions
92     //---------------------------------------------------------------------------------------------
94     function loadIndex(index) {
95         history.push(["mc", "video", root.pageModel[index].name]);
96     }