VideoListDisplay.qml 4.33 KB
Newer Older
Abel Tesfaye's avatar
Abel Tesfaye committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*****************************************************************************
 * Copyright (C) 2019 VLC authors and VideoLAN
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * ( at your option ) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQml.Models 2.2

import org.videolan.medialib 0.1

24
import "qrc:///util" as Util
25
import "qrc:///widgets/" as Widgets
26
import "qrc:///main/" as MainInterface
Abel Tesfaye's avatar
Abel Tesfaye committed
27
28
import "qrc:///style/"

29
MainInterface.MainTableView {
Abel Tesfaye's avatar
Abel Tesfaye committed
30
    id: listView_id
31

32
33
34
35
36
37
38
39
40
41
    //---------------------------------------------------------------------------------------------
    // Properties
    //---------------------------------------------------------------------------------------------

    // NOTE: This is useful for groups because our main criteria is 'name' instead of 'title'.
    property string mainCriteria: "title"

    //---------------------------------------------------------------------------------------------
    // Private

42
43
    readonly property int _nbCols: VLCStyle.gridColumnsForWidth(listView_id.availableRowWidth)

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
    //---------------------------------------------------------------------------------------------
    // Settings
    //---------------------------------------------------------------------------------------------

    sortModel: [{
        type: "image",

        criteria: "thumbnail",

        width: VLCStyle.colWidth(1),

        showSection: "",

        headerDelegate: tableColumns.titleHeaderDelegate,
        colDelegate   : tableColumns.titleDelegate,
    }, {
        isPrimary: true,
        criteria: mainCriteria,

        width: VLCStyle.colWidth(Math.max(listView_id._nbCols - 2, 1)),

        showSection: "title",

        text: i18n.qtr("Title")
    }, {
69
        criteria: "duration",
70
71
72
73
74
75
76
77

        width: VLCStyle.colWidth(1),

        showSection: "",

        headerDelegate: tableColumns.timeHeaderDelegate, showContextButton: true,
        colDelegate   : tableColumns.timeColDelegate
    }]
78
79
80

    section.property: "title_first_symbol"

81
    rowHeight: VLCStyle.tableCoverRow_height
82

Abel Tesfaye's avatar
Abel Tesfaye committed
83
84
    headerColor: VLCStyle.colors.bg

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
    //---------------------------------------------------------------------------------------------
    // Connections
    //---------------------------------------------------------------------------------------------

    Connections {
        target: model
        onSortCriteriaChanged: {
            switch (model.sortCriteria) {
            case "title":
                listView_id.section.property = "title_first_symbol"
                break;
            default:
                listView_id.section.property = ""
            }
        }
    }

Benjamin Arnaud's avatar
Benjamin Arnaud committed
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
    //---------------------------------------------------------------------------------------------
    // Functions
    //---------------------------------------------------------------------------------------------
    // Events

    function onLabels(model)
    {
        if (model === null)
            return [];

        return [
            model.resolution_name || "",
            model.channel         || ""
        ].filter(function(a) { return a !== "" });
    }

118
119
120
    //---------------------------------------------------------------------------------------------
    // Childs
    //---------------------------------------------------------------------------------------------
121

122
123
    Widgets.TableColumns {
        id: tableColumns
124
125
126
127
128
129
130

        showTitleText: false
        titleCover_height: VLCStyle.listAlbumCover_height
        titleCover_width: VLCStyle.listAlbumCover_width
        titleCover_radius: VLCStyle.listAlbumCover_radius

        function titlecoverLabels(model) {
Benjamin Arnaud's avatar
Benjamin Arnaud committed
131
            return listView_id.onLabels(model);
132
        }
133
    }
Abel Tesfaye's avatar
Abel Tesfaye committed
134
}