2 * Copyright (C) 2013-2015 Canonical, Ltd.
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.
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.
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/>.
18 import Ubuntu.Components 1.3
19 import Ubuntu.Components.ListItems 1.3 as ListItems
20 import "Filters" as Filters
21 import "../Components"
26 readonly property real searchesHeight: recentSearchesRepeater.count > 0 ? searchColumn.height + recentSearchesLabels.height + recentSearchesLabels.anchors.topMargin : 0
28 implicitHeight: searchesHeight + dashNavigation.implicitHeight + dashNavigation.anchors.topMargin + primaryFilterContainer.height + primaryFilterContainer.anchors.topMargin
31 property ListModel searchHistory
32 property var scope: null
33 property real windowHeight
36 readonly property bool hasContents: searchHistory.count > 0 || scope && scope.hasNavigation || scope && scope.primaryNavigationFilter
38 signal historyItemClicked(string text)
39 signal dashNavigationLeafClicked()
40 signal extraPanelOptionSelected()
42 function resetNavigation() {
43 dashNavigation.resetNavigation();
51 ListItems.ThinDivider {
52 anchors.top: parent.top
56 id: recentSearchesLabels
57 text: i18n.tr("Recent Searches")
58 visible: recentSearchesRepeater.count > 0
63 topMargin: units.gu(3)
68 text: i18n.tr("Clear All")
70 visible: recentSearchesRepeater.count > 0
75 topMargin: units.gu(3)
80 onClicked: searchHistory.clear();
87 top: recentSearchesLabels.bottom
93 id: recentSearchesRepeater
94 objectName: "recentSearchesRepeater"
97 // FIXME Move to ListItem once 1556971 is fixed
98 delegate: ListItems.Empty {
102 leftMargin: units.gu(2)
103 rightMargin: units.gu(2)
110 verticalCenter: parent.verticalCenter
113 height: units.gu(1.5)
120 verticalCenter: parent.verticalCenter
121 left: searchIcon.right
122 leftMargin: units.gu(1)
127 elide: Text.ElideRight
130 divider.visible: index != recentSearchesRepeater.count - 1 || (scope && scope.hasNavigation) || primaryFilter.active
132 onClicked: root.historyItemClicked(query)
141 top: recentSearchesRepeater.count > 0 ? searchColumn.bottom : parent.top
142 topMargin: implicitHeight && recentSearchesRepeater.count > 0 ? units.gu(2) : 0
146 availableHeight: windowHeight * 4 / 6 - searchesHeight
148 onLeafClicked: root.dashNavigationLeafClicked();
152 id: primaryFilterContainer
153 objectName: "primaryFilterContainer"
156 if (!primaryFilter.active) {
158 } else if (contentHeight > dashNavigation.availableHeight) {
159 return dashNavigation.availableHeight;
161 return contentHeight;
166 contentHeight: primaryFilter.implicitHeight
169 top: recentSearchesRepeater.count > 0 ? searchColumn.bottom : parent.top
170 topMargin: primaryFilter.active && recentSearchesRepeater.count > 0 ? units.gu(2) : 0
175 Filters.FilterWidgetFactory {
177 objectName: "primaryFilter"
179 active: scope && !scope.hasNavigation
182 property var filter: active ? scope.primaryNavigationFilter : null
184 widgetId: filter ? filter.filterId : ""
185 widgetType: filter ? filter.filterType : -1
188 onSingleSelectionFilterSelected: extraPanelOptionSelected()
192 // This is outside the item
199 fillMode: Image.Stretch
200 source: "graphics/navigation_shadow.png"