Unity 8
FiltersPopover.qml
1 /*
2  * Copyright (C) 2013-2015 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 as published by
6  * the Free Software Foundation; version 3.
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 
17 import QtQuick 2.4
18 import Ubuntu.Components 1.3
19 import Ubuntu.Components.Popups 1.3
20 import Ubuntu.Components.ListItems 1.3 as ListItems
21 import "Filters" as Filters
22 import "../Components"
23 
24 Popover {
25  id: root
26  objectName: "filtersPopover"
27 
28  Flickable {
29  id: flickable
30  anchors {
31  top: parent.top
32  left: parent.left
33  right: parent.right
34  }
35  height: {
36  // Popover doesn't like being 75% or bigger than the screen (counting the "empty" part on top)
37  var posToRootParent = flickable.mapToItem(null, 0, 0).y;
38  var threeQuartersParent = root.parent.height * 3 / 4 - posToRootParent - 1;
39  var parentAndKeyboard = root.parent.height - posToRootParent - (Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height + units.gu(3) : 0)
40  return Math.min(parentAndKeyboard, Math.min(threeQuartersParent, column.height));
41  }
42  clip: true
43  contentHeight: column.height
44  contentWidth: width
45 
46  Column {
47  id: column
48  width: parent.width
49 
50  Item {
51  width: parent.width
52  height: resetLabel.height + units.gu(3)
53 
54  Label {
55  anchors {
56  left: parent.left
57  right: resetLabel.left
58  margins: units.gu(2)
59  verticalCenter: parent.verticalCenter
60  }
61  text: i18n.tr("Refine your results")
62  }
63  Label {
64  id: resetLabel
65  anchors {
66  right: parent.right
67  rightMargin: units.gu(2)
68  verticalCenter: parent.verticalCenter
69  }
70  text: i18n.tr("Reset")
71 
72  AbstractButton {
73  anchors {
74  fill: parent
75  rightMargin: units.gu(-2)
76  leftMargin: units.gu(-2)
77  topMargin: units.gu(-1)
78  bottomMargin: units.gu(-1)
79  }
80  onClicked: {
81  scopeView.scope.resetFilters();
82  }
83  }
84  }
85  }
86 
87  Repeater {
88  id: repeater
89  model: scopeView.scope.filters
90 
91  delegate: Filters.FilterWidgetFactory {
92  width: parent.width
93 
94  widgetId: id
95  widgetType: type
96  widgetData: filter
97 
98  ListItems.ThinDivider {
99  anchors.bottom: parent.bottom
100  visible: index != repeater.count - 1
101  }
102  }
103  }
104  }
105  }
106 }