ListView {
id: listViewGrowers
property int sortedCol: Constants.LIST_SORT_NAME_UP
//delegate for tablets
Component {
id: growerDelegateTablet
Rectangle {
id:delegateContent
width: listViewGrowers.width
height: visible?DisplayInfo.lineheight * 3:0
color: "transparent"
NavLine {
id: line
width: parent.width
anchors.top: parent.top
anchors.leftMargin: 0
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.inputMethod.hide()
growerListContent.visible = false
growerItemSelected(model.modelData)
}
}
Rectangle {
id: imageStars
anchors.left: parent.left
anchors.top: line.bottom
width: parent.width * 0.2
height: parent.height
color: (listViewGrowers.sortedCol == Constants.LIST_SORT_STARS_UP || listViewGrowers.sortedCol == Constants.LIST_SORT_STARS_DOWN)?Theme.selected_col:"transparent"
Image {
asynchronous: true
anchors.top: parent.top
anchors.topMargin: DisplayInfo.lineheight * 0.5
anchors.left: parent.left
anchors.leftMargin: DisplayInfo.marginunit * 5
fillMode: Image.PreserveAspectFit
source: ("qrc:///icons/star_" + model.stars)
height: DisplayInfo.lineheight * 0.8
}
}
Rectangle {
id: textGrower
anchors.left: imageStars.right
anchors.top: line.bottom
width: parent.width * 0.4
height: parent.height
color: (listViewGrowers.sortedCol == Constants.LIST_SORT_NAME_UP || listViewGrowers.sortedCol == Constants.LIST_SORT_NAME_DOWN)?Theme.selected_col:"transparent"
StyledText {
text: model.name
anchors.left: parent.left
anchors.leftMargin: DisplayInfo.marginunit * 2
anchors.top: parent.top
anchors.topMargin: DisplayInfo.lineheight * 0.5
}
Component.onCompleted: {console.log("drawed: " + model.name)}
}
Rectangle {
id: imageGrowerLogo
width: DisplayInfo.lineheight * 3.0
height: parent.height
anchors.left: textGrower.right
anchors.top: line.bottom
color: (listViewGrowers.sortedCol == Constants.LIST_SORT_NAME_UP || listViewGrowers.sortedCol == Constants.LIST_SORT_NAME_DOWN)?Theme.selected_col:"transparent"
Image {
asynchronous: true
source: "qrc:///icons/logo_dummy"
anchors.centerIn: parent
sourceSize.height: DisplayInfo.lineheight * 2.8
sourceSize.width: DisplayInfo.lineheight * 2.8
}
}
Rectangle {
id: region
anchors.left: imageGrowerLogo.right
anchors.top: line.bottom
width: parent.width * 0.2
height: parent.height
color: (listViewGrowers.sortedCol == Constants.LIST_SORT_REGION_UP || listViewGrowers.sortedCol == Constants.LIST_SORT_REGION_DOWN)?Theme.selected_col:"transparent"
StyledText {
anchors.top: parent.top
anchors.topMargin: DisplayInfo.lineheight * 0.5
anchors.left: parent.left
anchors.leftMargin: DisplayInfo.marginunit * 2
text: model.region
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.inputMethod.hide()
console.log('region selected: ' + model.region)
}
}
}
Rectangle {
id: addtionalnfo
anchors.left: region.right
anchors.top: line.bottom
//width is listview filling
width: parent.width - (imageStars.width + textGrower.width + imageGrowerLogo + region)
height: parent.height
color: "transparent"
Image {
id: bioFlag
asynchronous: true
source: "qrc:///icons/bio"
anchors.top: parent.top
anchors.topMargin: DisplayInfo.lineheight * 0.5
anchors.left: parent.left
anchors.leftMargin: DisplayInfo.marginunit * 2
sourceSize.height: DisplayInfo.lineheight
sourceSize.width: DisplayInfo.lineheight
visible: model.bio
}
Image {
id: newFlag
source: "qrc:///icons/new"
asynchronous: true
anchors.top: parent.top
anchors.topMargin: DisplayInfo.lineheight * 0.5
anchors.left: bioFlag.right
anchors.leftMargin: DisplayInfo.marginunit * 2
sourceSize.height: DisplayInfo.lineheight
sourceSize.width: DisplayInfo.lineheight
visible: model.isNew
}
}
}
}
//delegate for phones
Component {
id: growerDelegatePhone
Rectangle {
width: ListView.width
height: DisplayInfo.lineheight * 3
}
}
Connections {
target: filterDialog;
onApplied: {
filterItem.stars = filterDialog.selStars
filterItem.onlyBio = filterDialog.selBio
filterItem.onlyNew = filterDialog.selNew
filterItem.regions = filterDialog.propregions
growers.filterSettings(filterItem, textFilter.text)
}
}
Connections {
target: filterDialog;
onCanceledFilter: {
filterItem.stars = filterDialog.selStars
filterItem.onlyBio = filterDialog.selBio
filterItem.onlyNew = filterDialog.selNew
filterItem.regions = filterDialog.propregions
growers.filterSettings(filterItem, textFilter.text)
}
}
FilterGrower{
id: filterItem
}
width: DisplayInfo.isLowRes?parent.width:parent.width * 0.9
anchors.top: header.bottom
anchors.topMargin: DisplayInfo.lineheight
anchors.bottom: growerListContent.bottom
anchors.bottomMargin: DisplayInfo.lineheight * 4
anchors.horizontalCenter: parent.horizontalCenter
clip: true
model: growers.growers
//delegate switched depending if tablet or smartphone
delegate: DisplayInfo.isTablet?growerDelegateTablet:growerDelegatePhone
//cacheBuffer: 60
onDragStarted: {
Qt.inputMethod.hide()
}
Component.onCompleted: {
console.log("listviewcompleted")
}
}
Bookmarks