chore: add itemData implementation for RoleGroupModel - #1693
Conversation
为 RoleGroupModel 补充 itemData() 实现. 这可以使调试 RoleGroupModel 时看到的信息稍佳清晰. Log:
Reviewer's GuideImplements RoleGroupModel::itemData to expose both standard and custom role values for a given index, improving debuggability and tooling support, and wires it into the model interface by declaring the override in the header. Sequence diagram for RoleGroupModel itemData implementationsequenceDiagram
participant Caller
participant RoleGroupModel
Caller->>RoleGroupModel: itemData(index)
activate RoleGroupModel
loop standard_roles
RoleGroupModel->>RoleGroupModel: data(index, role)
RoleGroupModel-->>RoleGroupModel: QVariant
end
RoleGroupModel->>RoleGroupModel: roleNames()
RoleGroupModel-->>RoleGroupModel: QHash<int, QByteArray>
loop custom_roles
RoleGroupModel->>RoleGroupModel: data(index, roleKey)
RoleGroupModel-->>RoleGroupModel: QVariant
end
RoleGroupModel-->>Caller: QMap<int, QVariant>
deactivate RoleGroupModel
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 QMap<int, QVariant> RoleGroupModel::itemData(const QModelIndex &index) const
{
QMap<int, QVariant> roles;
if (!index.isValid()) {
return roles;
}
for (int i = 0; i < Qt::UserRole; ++i) {
const QVariant value = data(index, i);
if (value.isValid())
roles.insert(i, value);
}
const auto names = roleNames();
for (auto it = names.cbegin(); it != names.cend(); ++it) {
const QVariant value = data(index, it.key());
if (value.isValid())
roles.insert(it.key(), value);
}
return roles;
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, Ivy233 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
为 RoleGroupModel 补充 itemData() 实现. 这可以使调试 RoleGroupModel 时看到的信息稍佳清晰.
Log:
Summary by Sourcery
Enhancements: