Debian Codegraph @

src/app/qml/views/FolderIconView.qml

raw
1 /*
2 * Copyright (C) 2013 Canonical Ltd
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 version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Michael Spencer <[email protected]>
17 */
18 import QtQuick 2.4
19 import Lomiri.Components 1.3
20 import Lomiri.Components.Popups 1.3
21
22 ScrollView {
23 id: folderIconView
24
25 property var folderListPage
26 property var fileOperationDialog
27 property var folderModel
28 property var selectedItem
29 property var openDefault
30
31 property alias footer: view.footer
32 property alias header: view.header
33
34 function calcCellwidth () {
35 var s = 12 // default
36 switch (globalSettings.gridSize) {
37 case 0: s = 10
38 break
39 case 1: s = 12
40 break
41 case 2: s = 16
42 break
43 case 3: s = 22
44 break
45 }
46 return folderListPage.width / ((folderListPage.width / units.gu(s)).toFixed(0))
47 }
48
49 GridView {
50 id: view
51 anchors.fill: parent
52
53 cellWidth: calcCellwidth()
54 cellHeight: cellWidth + units.gu(2)
55
56 model: folderModel.model
57
58 PullToRefresh {
59 onRefresh: {
60 refreshing = true
61 folderModel.goTo(folderModel.model.filePath)
62 refreshing = false
63 }
64 }
65
66 delegate: FolderIconDelegate {
67 id: delegate
68 width: view.cellWidth
69 height: view.cellHeight
70
71 iconName: model.iconName
72 title: model.stylizedFileName
73 isSelected: model.isSelected
74 path: model.filePath
75
76 property var __delegateActions: FolderDelegateActions {
77 folderListPage: folderIconView.folderListPage
78 folderModel: folderIconView.folderModel
79 fileOperationDialog: folderIconView.fileOperationDialog
80 openDefault: folderIconView.openDefault
81 }
82
83 onClicked: {
84 if (mouse.button === Qt.RightButton) {
85 delegate.pressAndHold(mouse)
86 } else {
87 __delegateActions.itemClicked(model)
88 }
89 }
90
91 onPressAndHold: {
92 folderModel.primSelItem = model
93 __delegateActions.listLongPress(model)
94 }
95 }
96 }
97 }