2
* Copyright (C) 2012, 2013 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 0.1
21
property var model: undefined
23
// Hud gives lots of results, make sure we have 5 at most
24
// FIXME This should use SortFilterProxyModel
25
// but there is a problem with the hud-service refreshing the
26
// data for no reason so we use the internal model + timer
27
// to fix those issues
34
// Accumulate count changes since hud clears
35
// and then readds items to the models which means
36
// even if the result is the same we get lots of count changes
37
onCountChanged: updateModelTimer.restart()
40
onModelChanged: updateModelTimer.restart()
45
onTriggered: updateModel()
48
function updateModel() {
50
for (var i = 0; i < 5 && i < model.count; ++i) {
51
var itemData = model.get(i)
52
internalModel.append({"name": itemData.column_1, "highlights": itemData.column_2, "context": itemData.column_3, "contextHighlights": itemData.column_4})
56
signal activated(int index)
58
height: repeater.height
62
objectName: "resultListRepeater"
67
height: result.height + separatorLine.height * 2
68
anchors.left: parent.left
69
anchors.right: parent.right
71
onClicked: activated(index)
75
anchors.top: parent.top
76
anchors.left: parent.left
77
anchors.right: parent.right
78
source: "graphics/divider.sci"
85
anchors.top: separatorLine.bottom
86
anchors.left: parent.left
87
anchors.right: parent.right
90
nameHighlights: highlights
91
contextSnippetText: context
92
contextSnippetHighlights: contextHighlights
96
anchors.top: result.bottom
97
anchors.left: parent.left
98
anchors.right: parent.right
99
source: "graphics/divider.sci"
102
Component.onCompleted: fadeIn.start()
103
NumberAnimation { id: fadeIn; target: resultList; alwaysRunToEnd: true; property: "opacity"; duration: 200; from: 0; to: 1 }