Howdy,
I'm having this little issue when returning only those items which
matches to data in SilicaListView taken from XmlListModel.
At the moment I do not have my complete source code because I'm working
but here's an example:
XmlListModel
{
id: xml_Database
source: "http://www.database.com/xml"
query: "/main"
XmlRole { name: "title"; query: "title/string()" }
XmlRole { name: "subtitle"; query: "description/string()" }
}
SilicaListView
{
id: list_Database
width: parent.width
height: parent.height
PullDownMenu
{
SearchField
{
id: search_Database
width: parent.width
font.pixelSize: Theme.fontSizeTiny
font.bold: false
color: Theme.highlightColor
placeHolderText: "Search"
placeHolderColor: Theme.secondaryHighlightColor
}
}
header: PageHeader
{
title: "Results"
}
model: xml_Database
delegate: Item
{
width: ( parent.width - ( 2.0 * Theme.paddingLarge ))
height: column_Database
Column
{
id: column_Database
spacing: Theme.paddingSmall
Label
{
text: Theme.highlightText ( model.title,
search_Database.text, Theme.highlightColor )
font.pixelSize: Theme.fontSizeSmall
font.bold: false
color: Theme.primaryColor
}
Label
{
text: model.subtitle
font.pixelSize: Theme.fontSizeExtraSmall
font.bold: false
color: Theme.secondaryColor
}
}
}
ViewPlaceHolder
{
text: "No results"
enabled: (( list_Database.count === 0.0 ) ? true : false )
visible: (( list_Database.count === 0.0 ) ? true : false )
}
VerticalScrollDecorator
{
flickable: list_Database
}
}
So this is just a small part of my code but basically this should hold
the problem.
When I pull down the pulley menu I can access the SearchField component.
After that I write something in it and if it can find exactly the same
string from the results (and to be precise, from 'model.title') it
returns that part in a 'Theme.highlightColor' instead of
'Theme.primaryColor'.
Okay, brilliant. But what if I want to only return those items that
actually match the entered search string? Let's say I get 50+ results in
a SilicaListView element and I want that user is able to filter the
results with the SearchField component.
How am I able to achieve this?
Oh, and I don't know anything about C++ so I hope this can be done
either with QML or JavaScript - or both of them.
Sincerely,
Heikki Kullas
P.S. The code might give some errors because I'm at work and I just
wrote it but it should demonstrate the idea and the issue I can not
solve by myself.
_______________________________________________
SailfishOS.org Devel mailing list