MCPcopy Create free account
hub / github.com/KDAB/GammaRay / setModelIndex

Method setModelIndex

plugins/modelinspector/modelcellmodel.cpp:35–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35void ModelCellModel::setModelIndex(const QModelIndex &idx)
36{
37 const auto newRoles = rolesForModel(idx.model());
38 if (newRoles != m_roles) {
39 if (!m_roles.isEmpty()) {
40 beginRemoveRows(QModelIndex(), 0, m_roles.size() - 1);
41 m_roles.clear();
42 endRemoveRows();
43 }
44 m_index = idx;
45 if (!newRoles.isEmpty()) {
46 beginInsertRows(QModelIndex(), 0, newRoles.size() - 1);
47 m_roles = newRoles;
48 endInsertRows();
49 }
50 } else {
51 m_index = idx;
52 if (!m_roles.isEmpty()) {
53 emit dataChanged(index(0, 1), index(rowCount() - 1, 1));
54 }
55 }
56}
57
58QVector<ModelCellModel::RoleInfo> ModelCellModel::rolesForModel(const QAbstractItemModel *model)
59{

Callers 2

modelSelectedMethod · 0.80
cellSelectionChangedMethod · 0.80

Calls 5

QModelIndexClass · 0.70
modelMethod · 0.45
isEmptyMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by 2

modelSelectedMethod · 0.64
cellSelectionChangedMethod · 0.64