@@ -24,39 +24,46 @@ Item {
26 property OpenEffect openEffect: null
26 property OpenEffect openEffect: null
27− property ScopeListView categoryView: null
28 property Scope scope: null
27 property Scope scope: null
29 property var pageHeader: null
28 property var pageHeader: null
31 property alias open: previewListView.open
30 property alias open: previewListView.open
32 property alias onScreen: previewListView.onScreen
31 property alias onScreen: previewListView.onScreen
33− property alias categoryId: previewListView.categoryId
34− property alias categoryDelegate: previewListView.categoryDelegate
35 property alias model: previewListView.model
32 property alias model: previewListView.model
36 property alias currentIndex: previewListView.currentIndex
33 property alias currentIndex: previewListView.currentIndex
37 property alias currentItem: previewListView.currentItem
34 property alias currentItem: previewListView.currentItem
38 property alias count: previewListView.count
35 property alias count: previewListView.count
40− Image {
37+ PageHeader {
41− objectName: "pointerArrow"
38+ id: header
42− anchors {
39+ anchors.topMargin: openEffect.topGapPx
43− top: previewListView.bottom
44− left: parent.left
40+ width: parent.width
45− leftMargin: previewListView.categoryDelegate !== undefined && previewListView.categoryDelegate.currentItem ?
41+ searchEntryEnabled: false
46− previewListView.categoryDelegate.currentItem.x + previewListView.categoryDelegate.currentItem.width / 2 + (-width + margins) / 2 : 0
42+ scope: root.scope
47−
43+ height: units.gu(8.5)
48− Behavior on leftMargin {
44+ showBackButton: true
49− SmoothedAnimation {
45+ onBackClicked: {
50− duration: UbuntuAnimation.FastDuration
46+ visibleOnce = false;
49+ visible: previewListView.open && previewListView.currentItem && previewListView.currentItem.ready || visibleOnce
50+ onVisibleChanged: visibleOnce = visible
51+ property bool visibleOnce: false
58+ verticalCenter: parent.verticalCenter
60+ text: scope ? i18n.tr("%1 Preview").arg(scope.name) : ""
62+ font.family: "Ubuntu"
63+ font.weight: Font.Light
65+ elide: Text.ElideRight
56− property int margins: previewListView.categoryDelegate ? previewListView.categoryDelegate.margins : 0
57− opacity: previewListView.open ? .5 : 0
59− source: "graphics/tooltip_arrow.png"
62 ListView {
69 ListView {
@@ -64,8 +71,7 @@ Item {
64 objectName: "previewListView"
71 objectName: "previewListView"
65 height: openEffect.bottomGapPx - openEffect.topGapPx
72 height: openEffect.bottomGapPx - openEffect.topGapPx
67− top: parent.top
74+ top: header.bottom
68− topMargin: openEffect.topGapPx
69 left: parent.left
75 left: parent.left
70 right: parent.right
76 right: parent.right
@@ -80,65 +86,19 @@ Item {
81 // To be set before opening the preview
87 // To be set before opening the preview
82 property string categoryId: ""
88 property string categoryId: ""
83− property var categoryDelegate
85 // because the ListView is built asynchronous, setting the
90 // because the ListView is built asynchronous, setting the
86 // currentIndex directly won't work. We need to refresh it
91 // currentIndex directly won't work. We need to refresh it
87 // when the first preview is ready to be displayed.
92 // when the first preview is ready to be displayed.
88 property bool init: true
93 property bool init: true
90− onCurrentIndexChanged: positionListView();
92− function positionListView() {
93− if (!open || currentIndex < 0) {
97− var row = Math.floor(currentIndex / categoryDelegate.columns);
98− if (categoryDelegate.collapsedRowCount <= row) {
99− categoryView.expandedCategoryId = categoryId
102− categoryDelegate.highlightIndex = currentIndex
104− // Adjust contentY in case we need to change to it to show the next row
105− if (categoryDelegate.rows > 1) {
106− var itemY = categoryView.contentItem.mapFromItem(categoryDelegate.currentItem).y;
108− // Find new contentY and effect.postionPx
109− var newContentY = itemY - openEffect.positionPx - categoryDelegate.verticalSpacing;
111− // Make sure the item is not covered by a header. Move the effect split down if necessary
112− var headerHeight = pageHeader.height + categoryView.stickyHeaderHeight;
113− var effectAdjust = Math.max(openEffect.positionPx, headerHeight);
115− // Make sure we don't overscroll the listview. If yes, adjust effect position
116− if (newContentY < 0) {
117− effectAdjust += newContentY;
119− } else if (categoryView.contentHeight < categoryView.height) {
120− // We can't change contentY if the content is smaller than the view, so adjust effect position
121− effectAdjust += newContentY;
123− } else if (newContentY > categoryView.contentHeight - categoryView.height) {
124− effectAdjust += -(categoryView.contentHeight - categoryView.height) + newContentY
125− newContentY = categoryView.contentHeight - categoryView.height;
128− openEffect.positionPx = effectAdjust;
129− categoryView.contentY = newContentY;
133 property bool open: false
95 property bool open: false
134 property bool onScreen: false
96 property bool onScreen: false
136 onOpenChanged: {
98 onOpenChanged: {
137 if (open) {
99 if (open) {
138 onScreen = true;
100 onScreen = true;
139− categoryDelegate.highlightIndex = currentIndex;
140 pageHeader.unfocus();
101 pageHeader.unfocus();
143 // Cancel any pending preview requests or actions
103 // Cancel any pending preview requests or actions
144 if (previewListView.currentItem.previewData !== undefined) {
104 if (previewListView.currentItem.previewData !== undefined) {
@@ -146,8 +106,6 @@ Item {
147 scope.cancelActivation();
107 scope.cancelActivation();
148 model = undefined;
108 model = undefined;
149− categoryView.correctExpandedCategory();
150− categoryDelegate.highlightIndex = -1;