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
25 readonly property real searchesHeight: recentSearchesRepeater.count > 0 ? searchColumn.height + recentSearchesLabels.height + recentSearchesLabels.anchors.topMargin : 0
27 implicitHeight: searchesHeight + dashNavigation.implicitHeight + dashNavigation.anchors.topMargin + primaryFilterContainer.height + primaryFilterContainer.anchors.topMargin
30 property ListModel searchHistory
31 property var scope: null
32 property real windowHeight
35 readonly property bool hasContents: searchHistory.count > 0 || scope && scope.hasNavigation || scope && scope.primaryNavigationFilter
37 signal historyItemClicked(string text)
38 signal dashNavigationLeafClicked()
39 signal extraPanelOptionSelected()
41 function resetNavigation() {
42 dashNavigation.resetNavigation();
50 ListItems.ThinDivider {
51 anchors.top: parent.top
55 id: recentSearchesLabels
56 text: i18n.tr("Recent Searches")
57 visible: recentSearchesRepeater.count > 0
62 topMargin: units.gu(3)
67 text: i18n.tr("Clear All")
69 visible: recentSearchesRepeater.count > 0
74 topMargin: units.gu(3)
79 onClicked: searchHistory.clear();
86 top: recentSearchesLabels.bottom
92 id: recentSearchesRepeater
93 objectName: "recentSearchesRepeater"
96 // FIXME Move to ListItem once 1556971 is fixed
97 delegate: ListItems.Empty {
101 leftMargin: units.gu(2)
102 rightMargin: units.gu(2)
109 verticalCenter: parent.verticalCenter
112 height: units.gu(1.5)
119 verticalCenter: parent.verticalCenter
120 left: searchIcon.right
121 leftMargin: units.gu(1)
128 divider.visible: index != recentSearchesRepeater.count - 1 || (scope && scope.hasNavigation) || primaryFilter.active
130 onClicked: root.historyItemClicked(query)
139 top: recentSearchesRepeater.count > 0 ? searchColumn.bottom : parent.top
140 topMargin: implicitHeight && recentSearchesRepeater.count > 0 ? units.gu(2) : 0
144 availableHeight: windowHeight * 4 / 6 - searchesHeight
146 onLeafClicked: root.dashNavigationLeafClicked();
150 id: primaryFilterContainer
151 objectName: "primaryFilterContainer"
154 if (!primaryFilter.active) {
156 } else if (contentHeight > dashNavigation.availableHeight) {
157 return dashNavigation.availableHeight;
159 return contentHeight;
164 contentHeight: primaryFilter.implicitHeight
167 top: recentSearchesRepeater.count > 0 ? searchColumn.bottom : parent.top
168 topMargin: primaryFilter.active && recentSearchesRepeater.count > 0 ? units.gu(2) : 0
173 Filters.FilterWidgetFactory {
175 objectName: "primaryFilter"
177 active: scope && !scope.hasNavigation
180 property var filter: active ? scope.primaryNavigationFilter : null
182 widgetId: filter ? filter.filterId : ""
183 widgetType: filter ? filter.filterType : -1
186 onSingleSelectionFilterSelected: extraPanelOptionSelected()
190 // This is outside the item
197 fillMode: Image.Stretch
198 source: "graphics/navigation_shadow.png"