import QtQuick 2.5
import QtQuick.Layouts 1.2
Rectangle
{
//RESOLVED: current stock always 0
//RESOLVED: show price
//BUG: change product's background according to current stock (red: currenstock<=20, disabled/greyed: currenstock<=0)
//TODO: handle service prodcuts (i.e., products which have not connection to stock)
property string ueParamProductImage: ""
property string ueParamProductName: ""
property string ueParamProductPriceSell: ""
property string ueParamProductCurrentStock: ""
radius: 16
clip: true
width: ueProductGridView.cellWidth-8
height: ueProductGridView.cellHeight-8
border.color: "#4682b4"
antialiasing: true
gradient: Gradient
{
GradientStop
{
position: 0
color: "#000000"
ParallelAnimation on color
{
id: ueProductSelectorDelegateMouseAreaAnimation
loops: 1
running: false
ColorAnimation
{
from: "#4682b4"
to: "#000000"
duration: 100
} // ColorAnimation
} // ParallelAnimation
} // GradientStop
GradientStop
{
position: 1
color: "#ffffff"
} // GradientStop
} // Gradient
MouseArea
{
id: ueDelegateMouseArea
anchors.fill: parent
onClicked:
{
var selectedIndex=ueProductGridView.currentIndex=index;
ueProductSelectorDelegateMouseAreaAnimation.running=true;
ueProductGridView.currentIndex=index;
ueOrdersModel.ueAddOrder(ueProductGridView.model.get(selectedIndex).ueRoleProductId,
1);
} // onClicked
} // MouseArea
ColumnLayout
{
anchors.fill: parent
antialiasing: true
spacing: 8
RowLayout
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.margins: 8
antialiasing: true
spacing: 8
Image
{
Layout.fillWidth: false
Layout.fillHeight: true
Layout.alignment: Qt.AlignLeft|Qt.AlignTop
fillMode: Image.PreserveAspectFit
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
antialiasing: true
source: ueParamProductImage
} // Image
Text
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignLeft|Qt.AlignTop
Layout.margins: 8
color: "steelblue"
text: ueParamProductName
wrapMode: Text.WordWrap
textFormat: Text.RichText
font.pointSize: 10
font.bold: true
style: Text.Normal
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignTop
} // Text
} // RowLayout
RowLayout
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.margins: 8
antialiasing: true
spacing: 8
Text
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignLeft|Qt.AlignVCenter
text: ueParamProductPriceSell
wrapMode: Text.NoWrap
textFormat: Text.RichText
font.pointSize: 10
font.bold: true
style: Text.Normal
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
} // Text
Text
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignRight|Qt.AlignVCenter
text: ueParamProductCurrentStock
wrapMode: Text.NoWrap
textFormat: Text.RichText
font.pointSize: 10
font.bold: true
style: Text.Normal
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
} // Text
} // RowLayout
} // ColumnLayout
transform:
[
Rotation
{
id: plateRotation
angle: -90
axis { x: 0; y: 1; z: 0 }
origin.x: -200
origin.y: 0
}
] // transform
SequentialAnimation
{
id: addAnimation
PauseAnimation
{
duration: Math.random()*2000
}
NumberAnimation
{
target: plateRotation
property: "angle"
to: 0
duration: 1000
//easing.type: Easing.InOutQuad
}
}
SequentialAnimation
{
id: removeAnimation
PropertyAction
{
target: ueProductSelectorDelegate
property: "GridView.delayRemove"
value: true
}
NumberAnimation
{
target: ueProductSelectorDelegate
property: "scale"
to: 0
duration: 1000
//easing.type: Easing.InOutQuad
}
PropertyAction
{
target: ueProductSelectorDelegate
property: "GridView.delayRemove"
value: false
}
}
GridView.onAdd:
{
print("onAdd");
addAnimation.start();
}
GridView.onRemove:
{
print("onRemove");
removeAnimation.start();
}
} // Rectangle
Bookmarks