CoverDocumentsView.qml 1,4 КБ
Newer Older
vladislav.larionov's avatar
vladislav.larionov включено в состав коммита
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
 * SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru>
 * SPDX-License-Identifier: Proprietary
 */

import QtQuick 2.0
import Sailfish.Silica 1.0

Item {
    id: root

    readonly property bool isGridMode: fileListModel.rowCount > documentsView.singleCoumnLimit

    readonly property bool isVertical: __cover.isPortrait

    readonly property alias __documentsView: root

    SilicaGridView {
        id: documentsView

        readonly property int singleCoumnLimit: 3
        readonly property int prefferedColumnCount: root.isVertical ? 2 : 3

        anchors {
            fill: parent
        }

        layer.enabled: true
        layer.effect: OpacityRampEffect {
            direction: OpacityRamp.TopToBottom
            sourceItem: documentsView
            slope: 4.0
            offset: __cover.isPortrait ? 0.5 : 0.42
        }

        model: fileListModel

        cellWidth: root.isGridMode
                   ? documentsView.width / documentsView.prefferedColumnCount
                   : documentsView.width

        cellHeight: (root.isGridMode ? Theme.dp(120)
                                     : Theme.dp(76)) + Theme.paddingSmall

        delegate: CoverDocumentDelegate {}
    }

    Component.onCompleted: {
        __cover.actionsEnable = true
    }

    Component.onDestruction: {
        __cover.actionsEnable = false
    }
}