forked from HuijunXu/CUMT-Daily
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewsList_Top.qml
139 lines (132 loc) · 4.12 KB
/
NewsList_Top.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import QtQuick 2.0
import TimeLine 1.0
Rectangle{
id: topNews //上方轮播部分
width: parent.width
height: parent.width*9/16+70*newsList.rate
color:"white"
function setModel(type){
console.log(type)
type = type+"1";
topNewsPic.model=TL.getNewsByType(type);
}
ListView{
id: topNewsPic
width: parent.width
height: parent.width*9/16
function set(position){
if(position<5||(position<width&&position>(width-250))){
// contentX=0
topNewsPic.currentIndex=0
picAnimation.to=0
picAnimation.from=position
picAnimation.restart()
}
else if(position<(width+5)||(position<2*width&&position>(2*width-250))){
// contentX=width
topNewsPic.currentIndex=1
picAnimation.to=width
picAnimation.from=position
picAnimation.restart()
}
else if(position<(2*width+5)||(position<3*width&&position>(3*width-250))){
// contentX=2*width
topNewsPic.currentIndex=2
picAnimation.to=2*width
picAnimation.from=position
picAnimation.restart()
}
else {
// contentX=3*width
topNewsPic.currentIndex=3
picAnimation.to=3*width
picAnimation.from=position
picAnimation.restart()
}
}
orientation: ListView.Horizontal
NumberAnimation on contentX {id:picAnimation;duration: 500 }
delegate: Image{
property string title:modelData.title
property string nid:modelData.id
width: root.width
height: root.width*9/16
Component.onCompleted: {
source= modelData.thumbnail
}
}
}
MouseArea{
width: root.width
height: root.width*9/16
anchors.top: topNews.top
anchors.left: topNews.left
property real xPress : -1
onPressed:
{
xPress = mouse.x
}
onMouseXChanged:
{
if(x==-1)
return;
topNewsPic.contentX += -(mouse.x- xPress)
xPress=mouse.x
// x = mouse.x
}
onMouseYChanged:
{
}
onReleased:
{
xPress= -1
topNewsPic.set(topNewsPic.contentX)
}
onClicked: {
if(topNewsPic.contentX%topNewsPic.width==0){
newsWindow.init(topNewsPic.currentItem.nid);
newsWindow.show();
}
}
}
Rectangle{
width: parent.width
height: 70*newsList.rate
color: "white"
anchors.bottom: parent.bottom
Text{
id:topNewsText
font.pixelSize: 30*newsList.rate
font.family: "微软雅黑"
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 10*newsList.rate
anchors.left: parent.left
color: "black"
text: topNewsPic.currentItem.title
}
Rectangle{
height: parent.height
width: 160*newsList.rate
anchors.right: parent.right
anchors.rightMargin: 20*newsList.rate
ListView{
id: topNewsStat
anchors.fill: parent
orientation: ListView.Horizontal
model: 4
delegate: Rectangle{
width: topNewsStat.width/4
height: topNewsStat.height
color: "transparent"
Rectangle{
anchors.centerIn: parent
width: topNewsPic.currentIndex==index?20*newsList.rate:15*newsList.rate
height: width
radius: 10*newsList.rate
color: topNewsPic.currentIndex===index?"red":"grey"
}
}
}
}
}
}