-
Notifications
You must be signed in to change notification settings - Fork 488
/
Copy pathQmlPageNavigation.qml
114 lines (108 loc) · 3.07 KB
/
QmlPageNavigation.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*!
*@file QmlPageNavigation.qml
*@brief Qml分页显示
*@version 1.0
*@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation
*@author zhengtianzuo
*/
import QtQuick 2.7
import QtQuick.Controls 2.0
Row{
id: pageNavigation
property int nCout: 1
property int nCurPage: 1
property int nPageSize: 1
signal sCurPage(int curPage);
Rectangle{
id: prevPage
height: 24
width: 60
color: "#EEEEEE"
border.color: "#AAAAAA"
border.width: 1
Row{
anchors.centerIn: parent
Image{
height: 16
width: 16
anchors.verticalCenter: parent.verticalCenter
source: "qrc:/arrow.png"
rotation: -180
}
Text {
font.family: "microsoft yahei"
font.pixelSize: 12
anchors.verticalCenter: parent.verticalCenter
text: qsTr("上一页")
}
}
MouseArea{
anchors.fill: parent
onClicked: {
if (pageNavigation.nCurPage > 1) pageNavigation.nCurPage--;
}
}
}
Repeater{
id: repeater
model: pageNavigation.nPageSize
delegate: Rectangle{
property int nCurIndex: (pageNavigation.nCurPage-1)*pageNavigation.nPageSize + index + 1
property bool hasPage: nCurIndex <= pageNavigation.nCout
height: 24
width: 24
color: hasPage ? "#EEEEEE" : "transparent"
border.color: "#AAAAAA"
border.width: hasPage ? 1 : 0
Text {
font.family: "microsoft yahei"
font.pixelSize: 12
anchors.centerIn: parent
text: nCurIndex
visible: hasPage ? true : false
}
MouseArea{
anchors.fill: parent
hoverEnabled: hasPage
onEntered: {
parent.color = "#148014"
}
onExited: {
parent.color = "#EEEEEE"
}
onPressed: {
emit: sCurPage(nCurIndex);
}
}
}
}
Rectangle{
id: nextPage
height: 24
width: 60
color: "#EEEEEE"
border.color: "#AAAAAA"
border.width: 1
Row{
anchors.centerIn: parent
Text {
font.family: "microsoft yahei"
font.pixelSize: 12
anchors.verticalCenter: parent.verticalCenter
text: qsTr("下一页")
}
Image{
height: 16
width: 16
anchors.verticalCenter: parent.verticalCenter
source: "qrc:/arrow.png"
}
}
MouseArea{
anchors.fill: parent
onClicked: {
if (pageNavigation.nCurPage*pageNavigation.nPageSize <= pageNavigation.nCout) pageNavigation.nCurPage++;
}
}
}
}