blob: af47a74a4cf9856a1e5515f6027a3d90a2b6a779 (
plain)
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
|
/***************************************************************************************************
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
***************************************************************************************************/
using Qt.Quick;
using UserViewLib;
namespace UserViewQml
{
internal class Program
{
public static IUserList Users { get; set; }
static void Main(string[] args)
{
Qml.LoadFromRootModule("Main");
bool listInit = false;
var rand = new Random();
while (!Qml.WaitForExit(100)) {
if (Users == null)
continue;
if (!listInit) {
listInit = true;
Users.AddRange(RandomUserService.Fetch(20)
.OrderBy(x => x, UserComparer.ByLastName)
.ToList());
continue;
}
var w = rand.Next(100);
if (w < 10) {
var removeIndex = rand.Next(Users.Count);
Users.RemoveAt(removeIndex);
} else if (w < 20) {
var newUser = RandomUserService.Fetch();
var index = Users.BinarySearch(newUser, UserComparer.ByLastName);
if (index < 0)
Users.Add(newUser, ~index);
}
}
}
}
}
|