Component
{
id:
delegate;
Item
{
id:
deleItem;
width:
xjsbList.width;
height:
deleRec.height;
property
int
idx:
index;
Rectangle
{
id:
deleRec;
width:
xjsbList.width;
height:
45*
pixelRate;
state:
"closeDraw"
Drag.active:
drawMouse.drag.active
onXChanged:
{
deleRec.emitEnable
=
false;
}
Rectangle
{
id:
split;
height:
1;
width:
parent.width;
anchors.bottom:
parent.bottom;
color:
"#E6E6E6";
}
property
bool
isClick:
false;
property
real
boundary:
20
*
pixelRate;
property
bool
emitEnable:
true;
signal
btnClicked();
NSText
{
id:
txt;
text:
qsTr(
"%1)
%2").arg(
deleItem.idx+1).arg(
sbListArray[
deleItem.idx].sbmc);
anchors.left:
parent.left;
anchors.leftMargin:
10*
pixelRate;
anchors.verticalCenter:
parent.verticalCenter;
Component.onCompleted:
{
console.log(
"-----------",
sbListArray[
deleItem.idx].sbmc,idx);
}
}
NSText
{
id:
status;
anchors.right:
img.left;
anchors.rightMargin:
5*
pixelRate;
anchors.verticalCenter:
parent.verticalCenter;
text:
"未完成";
}
Image
{
id:
img
anchors.right:
parent.right;
//anchors.rightMargin:
20*pixelRate;
source:
"qrc:/img/resource/img/arrow/greenRight_3.png";
sourceSize:
Qt.size(
deleRec.height*0.4,
deleRec.height*0.4);
anchors.verticalCenter:
parent.verticalCenter;
MouseArea
{
id:
mos;
anchors.fill:
parent;
onClicked:
{
deleRec.btnClicked();
}
}
}
function
moveToDeviceMgr(baseItem)
{
//选择设备进入设备台账信息页面
if(null
===
m_deviceMgr)
{
var
cmpnt
=
Qt.createComponent(
"DeviceSearchDSelectForm.qml");
if(
cmpnt.status
===
Component.Ready)
{
m_deviceMgr
=
cmpnt.createObject();
}
else
{
console.debug(
qsTr(
"错误:"),
cmpnt.errorString());
}
cmpnt.destroy();
}
if(null
!=
m_deviceMgr)
{
stackView.push(m_deviceMgr);
m_deviceMgr.updateContent(
baseItem);
}
}
states:
[
State
{
name:
"openDraw"
StateChangeScript{
script:
{
drawOpen.start();
}
}
},
State
{
name:
"closeDraw"
StateChangeScript{
script:
{
drawClose.start();
}
}
}
]
PropertyAnimation
on
x
{
id:
drawOpen
running:false
to:
drawMouse.drag.minimumX
easing.type:
Easing.InOutQuad
}
PropertyAnimation
on
x
{
id:
drawClose
running:false
to:
drawMouse.drag.maximumX
easing.type:
Easing.InOutQuad
}
MouseArea{
id:
drawMouse;
anchors.left:
parent.left;
anchors.right:
parent.right;
height:
parent.height;
//anchors.fill:
parent
drag.target:
parent
drag.axis:
Drag.XAxis
drag.maximumX:
0
drag.minimumX:
-
delBtn.width
property
point
oldPosition
onPressed:
{
oldPosition
=
Qt.point(
mouse.x,
mouse.y)
}
onReleased:
{
var
nowPosition
=
Qt.point(
mouse.x,
mouse.y)
//这里要判断一下是否是在隐藏按钮们隐藏的情况下按下的
xjsbList.forceActiveFocus();
if
(
deleRec.state
===
"closeDraw")
{
if(
deleRec.x
===
0
&&
deleRec.emitEnable
===
true){
emit:
deleRec.btnClicked();
}
else
if
((
deleRec.x
!==
0
&&
deleRec.x<=-
deleRec.boundary
&&
nowPosition.x-
oldPosition.x
<
0)){
deleRec.state
=
"openDraw";
}
else
{
drawClose.start();
}
}
else
{
deleRec.state
=
"closeDraw";
}
deleRec.emitEnable
=
true;
}
}
onBtnClicked:
{
console.log(
"-----------");
//deleRec.state
=
"closeDraw";
showxjListForm();
}
}
Rectangle
{
id:
delBtn;
anchors.left:
deleRec.right;
width:
parent.height;
height:
width;
color:
"#EB1111";
NSText
{
id:
txtt;
text:
"删除";
color:
"#FFFFFF";
anchors.centerIn:
parent;
}
MouseArea
{
anchors.fill:
parent;
onClicked:
{
sbListArray.splice(index,
1);
nModel
=
sbListArray.length;
}
}
}
}
}