~dandrader/unity8/surfaceDrawn

« back to all changes in this revision

Viewing changes to qml/Dash/Filters/FilterExpandableWidget.qml

  • Committer: CI Train Bot
  • Author(s): Albert Astals Cid
  • Date: 2016-05-04 18:09:25 UTC
  • mfrom: (1944.15.9 expandable_filter)
  • Revision ID: ci-train-bot@canonical.com-20160504180925-cey9wa2qnkh0yahw
Expandable Filter Widget
Approved by: Andrea Cimitan, Pawel Stolowski

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 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.ListItems 1.3 as ListItems
 
20
 
 
21
/*! Expandable Filter Widget. */
 
22
 
 
23
FilterWidget {
 
24
    id: root
 
25
 
 
26
    showsTitleOnItsOwn: true
 
27
 
 
28
    implicitHeight: expandingItem.height
 
29
 
 
30
    ListItems.Expandable {
 
31
        id: expandingItem
 
32
        objectName: "expandingItem"
 
33
 
 
34
        expandedHeight: collapsedHeight + column.height
 
35
        anchors.left: parent.left
 
36
        anchors.right: parent.right
 
37
        showDivider: false
 
38
 
 
39
        onClicked: {
 
40
            expanded = !expanded;
 
41
            forceActiveFocus();
 
42
        }
 
43
        __contentsMargins: 0
 
44
 
 
45
        Item {
 
46
            id: titleHolder
 
47
            anchors.top: parent.top
 
48
            height: expandingItem.collapsedHeight
 
49
            anchors.left: parent.left
 
50
            anchors.right: parent.right
 
51
 
 
52
            Label {
 
53
                anchors.left: parent.left
 
54
                anchors.leftMargin: units.gu(2)
 
55
                anchors.right: dropDown.left
 
56
                anchors.verticalCenter: parent.verticalCenter
 
57
                text: widgetData.title || ""
 
58
            }
 
59
 
 
60
            Image {
 
61
                id: dropDown
 
62
                height: units.gu(3)
 
63
                fillMode: Image.PreserveAspectFit
 
64
                anchors.right: parent.right
 
65
                anchors.rightMargin: units.gu(2)
 
66
                anchors.verticalCenter: parent.verticalCenter
 
67
                source: expandingItem.expanded ? "image://theme/up" : "image://theme/down"
 
68
            }
 
69
        }
 
70
 
 
71
        Column {
 
72
            id: column
 
73
            anchors.left: parent.left
 
74
            anchors.right: parent.right
 
75
            anchors.top: titleHolder.bottom
 
76
 
 
77
            Repeater {
 
78
                id: repeater
 
79
                model: widgetData.filters
 
80
 
 
81
                delegate: FilterWidgetFactory {
 
82
                    width: parent.width
 
83
 
 
84
                    widgetId: id
 
85
                    widgetType: type
 
86
                    widgetData: filter
 
87
 
 
88
                    ListItems.ThinDivider {
 
89
                        anchors.bottom: parent.bottom
 
90
                        visible: index !== repeater.count - 1
 
91
                    }
 
92
                }
 
93
            }
 
94
        }
 
95
    }
 
96
}