Newer
Older
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
140
141
142
143
144
145
import QtQuick.Window 2.2
import QtQuick.Controls 2.1
import QtQuick 2.0
import QtGraphicalEffects 1.0
DapLogsScreenForm
{
///@detalis firstMarginList First indent in the delegate to the first word.
property int firstMarginList: 16 * pt
///@detalis secondMarginList Second indent between the first and second word.
property int secondMarginList: 18 * pt
///@detalis thirdMarginList Third indent between the second and third word and the following.
property int thirdMarginList: 40 * pt
///@detalis fifthMarginList Fifth indent between the second and third word and the following.
property int fifthMarginList: 20 * pt
///@detalis fontSizeList Font size delegate.
property int fontSizeList: 16 * pt
///@detalis fontSizeHeader Font size header.
property int fontSizeHeader: 12 * pt
///@detalis fontFamily Font family.
property string fontFamily: "Roboto"
///@detalis Font color.
property string fontColor: "#070023"
///In this block, the properties are only auxiliary for internal use.
QtObject
{
id: privateDate
//Day
property int day: 86400
//Current time
property var today
property var todayDay
property var todayMonth
property var todayYear
property var stringTime
}
//Creates a list model for the example
Component.onCompleted: {
dapLogsListViewIndex = -1;
privateDate.today = new Date();
privateDate.todayDay = privateDate.today.getDate();
privateDate.todayMonth = privateDate.today.getMonth();
privateDate.todayYear = privateDate.today.getFullYear();
var timeString = new Date();
var day = new Date(86400);
var count = 1000
for (var i = 0; i < count; i++)
{
var momentTime = timeString/1000 - (day/6) * i;
var momentDay = getDay(momentTime);
dapLogsModel.append({"type":"DBG"+i, "info":"Add problems"+i, "file":"dup_chein"+i, "time":getTime(momentTime),
"date":getDay(momentTime)});
}
}
ListModel
{
id:dapLogsModel
}
//The Component Header
Component
{
id:delegateLogsHeader
Rectangle
{
height: 30 * pt
width: dapLogsListView.width
color: "#908D9D"
Text
{
anchors.fill: parent
anchors.topMargin: 8 * pt
anchors.bottomMargin: 8 * pt
anchors.leftMargin: firstMarginList
color: "#FFFFFF"
font.pixelSize: fontSizeHeader
font.family: fontFamily
text: section
}
}
}
//The component delegate
Component
{
id:delegateLogs
//Frame delegate
Rectangle
{
height: 60 * pt
width: dapLogsListView.width
color:
{
if(dapLogsListViewIndex === index)
{
return "#FAE5ED";
}
else
{
return "#FFFFFF";
}
}
//Event container
Rectangle
{
anchors.fill: parent
anchors.topMargin: 20 * pt
anchors.bottomMargin: 20 * pt
anchors.leftMargin: firstMarginList
anchors.rightMargin: fifthMarginList
color: parent.color
//Frame type log
Rectangle
{
id:frameTypeLog
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
width: 43 * pt
color: parent.color
Text
{
id: typeLog
anchors.fill: parent
font.pixelSize: fontSizeList
font.family: fontFamily
color: fontColor
text: type
}
}
// Frame text log
Rectangle
{
id:frameTextLog
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: frameTypeLog.right
anchors.right: frameFileLog.left
anchors.rightMargin: thirdMarginList
color: parent.color
Text
{
id: textLog
anchors.fill: parent
font.pixelSize: fontSizeList
font.family: fontFamily
color: fontColor
text: info
}
}
//Frame file log
Rectangle
{
id: frameFileLog
anchors.right: frameTimeLog.left
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.rightMargin: thirdMarginList
width: 326 * pt
color: parent.color
Text
{
id: fileLog
anchors.fill: parent
font.pixelSize: 14 * pt
font.family: fontFamily
color: fontColor
text: file
}
}
//Frame time log
Rectangle
{
id: frameTimeLog
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
width: 62 * pt
color: parent.color
Text
{
id: timeLog
anchors.fill: parent
font.pixelSize: fontSizeList
font.family: fontFamily
color: fontColor
text: time
}
}
}
//Underline bar
Rectangle
{
anchors.bottom: parent.bottom
color: "#E3E2E6"
width: parent.width
height: 1 * pt
}
MouseArea
{
anchors.fill: parent
onClicked:
{
dapLogsListViewIndex = index;
}
}
}
}
//This function converts the string representation of time to the Date format
function parceTime(thisTime)
{
var aDate = thisTime.split('-');
var aDay = aDate[0].split('/');
var aTime = aDate[1].split(':');
privateDate.stringTime = new Date(20+aDay[2], aDay[0] - 1, aDay[1], aTime[0], aTime[1], aTime[2]);
}
//Returns the time in the correct form for the delegate
function getTime(thisTime)
{
var tmpTime = new Date(thisTime * 1000)
var thisHour = tmpTime.getHours();
var thisMinute = tmpTime.getMinutes();
var thisSecond = tmpTime.getSeconds();
if(thisMinute<10) thisMinute = '0' + thisMinute;
if(thisSecond<10) thisSecond = '0' + thisSecond;
return thisHour + ':' + thisMinute + ':' + thisSecond;
}
//Returns the time in the correct form for the header
function getDay(thisTime)
{
var monthArray = ["January", "February", "March", "April", "May", "June", "July", "August", "September",
"October", "November", "December"];
var tmpDate = new Date(thisTime*1000);
var thisMonth = tmpDate.getMonth();
var thisDay = tmpDate.getDate();
var thisYear = tmpDate.getFullYear();
if(thisYear === privateDate.todayYear)
{
if(thisMonth === privateDate.todayMonth)
{
switch(thisDay){
case(privateDate.todayDay): return"Today";
case(privateDate.todayDay-1): return"Yesterday";
default: return monthArray[thisMonth] + ', ' + thisDay;
}
}
else
return monthArray[thisMonth] + ', ' + thisDay;
}
else
return monthArray[thisMonth] + ', ' + thisDay + ', ' + thisYear;
}
}