set properties from listView
This commit is contained in:
parent
f2fd2e880a
commit
693078b892
3 changed files with 14 additions and 10 deletions
|
|
@ -37,12 +37,14 @@ Item {
|
||||||
model: navigationList.pModelItems
|
model: navigationList.pModelItems
|
||||||
spacing: 20
|
spacing: 20
|
||||||
orientation: ListView.Horizontal
|
orientation: ListView.Horizontal
|
||||||
delegate:
|
delegate: NavigationListDelegate{
|
||||||
NavigationListDelegate{
|
|
||||||
id: delegate
|
id: delegate
|
||||||
|
property var delegateModel: navigationList.pModelItems[index]
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: height
|
width: height
|
||||||
model: navigationList.pModelItems[index]
|
isCircleDelegate: delegateModel.pIsCircleDelegate
|
||||||
|
imageSource: delegateModel.pImageSource
|
||||||
|
onClicked: delegateModel.onClicked();
|
||||||
} // NavigationListDelegate
|
} // NavigationListDelegate
|
||||||
} // ListView
|
} // ListView
|
||||||
} // Rectangle: List background
|
} // Rectangle: List background
|
||||||
|
|
|
||||||
|
|
@ -2,27 +2,29 @@ import QtQuick 2.11
|
||||||
import QtQuick.Controls 2.4
|
import QtQuick.Controls 2.4
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delegate of navigation list.
|
||||||
|
*
|
||||||
|
* The delegate is either a circle or a rectangle containing an image.
|
||||||
|
*/
|
||||||
ItemDelegate{
|
ItemDelegate{
|
||||||
id: container
|
id: container
|
||||||
|
|
||||||
property var model
|
property bool isCircleDelegate: true
|
||||||
property alias imageSource: contentImage.source
|
property alias imageSource: contentImage.source
|
||||||
|
|
||||||
|
|
||||||
padding: 5
|
padding: 5
|
||||||
onClicked:{
|
|
||||||
model.onClicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
background: Rectangle{
|
background: Rectangle{
|
||||||
id: background
|
id: background
|
||||||
implicitWidth: 150
|
implicitWidth: 150
|
||||||
implicitHeight: implicitWidth
|
implicitHeight: implicitWidth
|
||||||
radius: model.pIsCircleDelegate ? height/2 : 0
|
radius: container.isCircleDelegate ? height/2 : 0
|
||||||
color: "blue"
|
color: "blue"
|
||||||
Image{
|
Image{
|
||||||
id: contentImage
|
id: contentImage
|
||||||
source: model ? model.pImageSource : "qrc:/default_image"
|
source: "qrc:/default_image"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 5
|
anchors.margins: 5
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
NavigationListModel::NavigationListModel(QObject* parent) : QObject(parent)
|
NavigationListModel::NavigationListModel(QObject* parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
/*nothing*/
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QObject *> NavigationListModel::getModelItems()
|
QList<QObject *> NavigationListModel::getModelItems()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue