MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / fillSampleData

Method fillSampleData

test/cli/QML-Samples-TableView/samplemodel.cpp:47–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47void SampleModel::fillSampleData(int size)
48{
49 QString abs = "qwertyuiopasdfghjklzxcvbnm";
50 QRandomGenerator r;
51 for (auto i = 0; i < size; i++) {
52 Row row;
53 auto nameLen = r.bounded(3, 8);
54 QString name;
55 for (int c = 0; c < nameLen; ++c)
56 name.append(abs.at(r.bounded(0, abs.size() - 1)));
57
58 row.first = name;
59 row.second = r.bounded(0, 20);
60 _data.append(row);
61 }
62
63 qDebug() << _data.size() << "item(s) added as sample data";
64 beginInsertRows(QModelIndex(), 0, _data.size() - 1);
65 endInsertRows();
66}

Callers

nothing calls this directly

Calls 3

atMethod · 0.80
QModelIndexClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected