Unity 8
 All Classes Functions Properties
ScopeItem.qml
1 /*
2  * Copyright (C) 2014 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.0
18 import Ubuntu.Components 0.1
19 import Unity 0.2
20 import "../Components"
21 
22 Item {
23  id: root
24 
25  property alias scope: scopeView.scope
26  property alias previewOpen: previewListView.open
27 
28  property ListModel searchHistory
29 
30  signal back
31  signal gotoScope(string scopeId)
32  signal openScope(var scope)
33 
34  // TODO see how much code we can share
35  // between here and other Dash parts, it's starting to have
36  // too much duplicated code with the DashDepartments, etc
37 
38  Item {
39  id: scopeViewHolder
40 
41  x: previewListView.open ? -width : 0
42  Behavior on x { UbuntuNumberAnimation { } }
43  width: parent.width
44  height: parent.height
45 
46  GenericScopeView {
47  id: scopeView
48  width: parent.width
49  height: parent.height
50  isCurrent: scope != null
51  tabBarHeight: scopeItemPageHeader.implicitHeight
52  pageHeader: scopeItemPageHeader
53  previewListView: previewListView
54 
55  Connections {
56  target: scopeView.isCurrent ? scope : null
57  onGotoScope: root.gotoScope(scopeId);
58  onOpenScope: root.openScope(scope);
59  }
60  }
61 
62  PageHeader {
63  id: scopeItemPageHeader
64  width: parent.width
65  searchEntryEnabled: true
66  searchHistory: root.searchHistory
67  scope: root.scope
68  height: units.gu(8.5)
69  showBackButton: true
70  onBackClicked: root.back();
71 
72  childItem: Label {
73  id: label
74  anchors {
75  left: parent.left
76  right: parent.right
77  verticalCenter: parent.verticalCenter
78  }
79  text: scope ? scope.name : ""
80  color: "#888888"
81  font.family: "Ubuntu"
82  font.weight: Font.Light
83  fontSize: "x-large"
84  elide: Text.ElideRight
85  }
86 
87  bottomItem: DashDepartments {
88  scope: root.scope
89  width: parent.width <= units.gu(60) ? parent.width : units.gu(40)
90  anchors.right: parent.right
91  windowHeight: root.height
92  windowWidth: root.width
93  }
94  }
95  }
96 
97  PreviewListView {
98  id: previewListView
99  visible: x != width
100  pageHeader: scopeItemPageHeader
101  scope: root.scope
102  width: parent.width
103  height: parent.height
104  anchors.left: scopeViewHolder.right
105  }
106 }