2 * Copyright (C) 2014 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 "../../Components"
21 /*! \brief This component constructs the Preview UI.
23 * Currently it displays all the widgets in a flickable column.
29 /*! \brief Model containing preview widgets.
31 * The model should expose "widgetId", "type" and "properties" roles, as well as
32 * have a triggered(QString widgetId, QString actionId, QVariantMap data) method,
33 * that's called when actions are executed in widgets.
35 property var previewModel
37 //! \brief Should be set to true if this preview is currently displayed.
38 property bool isCurrent: false
40 //! \brief The ScopeStyle component.
41 property var scopeStyle: null
47 property: "widgetColumnCount"
59 anchors { fill: parent; margins: spacing }
61 property int columns: width >= units.gu(80) ? 2 : 1
62 property real columnWidth: width / columns
69 objectName: "previewListRow" + index
74 width: row.columnWidth
85 Behavior on contentY { UbuntuNumberAnimation { } }
87 delegate: PreviewWidgetFactory {
88 widgetId: model.widgetId
89 widgetType: model.type
90 widgetData: model.properties
91 isCurrentPreview: root.isCurrent
92 scopeStyle: root.scopeStyle
96 leftMargin: widgetMargins
97 rightMargin: widgetMargins
101 previewModel.triggered(widgetId, actionId, data);
105 oskScroller.setMakeSureVisibleItem(item);
108 onFocusChanged: if (focus) column.positionViewAtIndex(index, ListView.Contain)
110 onHeightChanged: if (focus) column.positionViewAtIndex(index, ListView.Contain)