aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/filter.go
blob: 48e8a7faedc1b82ffb82d69201c4e90813637fd7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package qt

import (
    "github.com/ethereum/go-ethereum/core"
    "github.com/ethereum/go-ethereum/ui"
    "github.com/obscuren/qml"
)

func NewFilterFromMap(object map[string]interface{}, eth core.Backend) *core.Filter {
    filter := ui.NewFilterFromMap(object, eth)

    if object["topics"] != nil {
        filter.SetTopics(makeTopics(object["topics"]))
    }

    return filter
}

func makeTopics(v interface{}) (d [][]byte) {
    if qList, ok := v.(*qml.List); ok {
        var s []string
        qList.Convert(&s)

        d = ui.MakeTopics(s)
    } else if str, ok := v.(string); ok {
        d = ui.MakeTopics(str)
    }

    return
}