File indexing completed on 2024-12-15 03:45:01
0001 /* 0002 SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #include "rolemappingproxymodel.h" 0008 0009 using namespace KUserFeedback::Console; 0010 0011 RoleMappingProxyModel::RoleMappingProxyModel(QObject* parent) : 0012 QIdentityProxyModel(parent) 0013 { 0014 } 0015 0016 RoleMappingProxyModel::~RoleMappingProxyModel() = default; 0017 0018 void RoleMappingProxyModel::addRoleMapping(int fromRole, int toRole) 0019 { 0020 m_roleMapping.insert(fromRole, toRole); 0021 } 0022 0023 QVariant RoleMappingProxyModel::data(const QModelIndex& index, int role) const 0024 { 0025 const auto it = m_roleMapping.find(role); 0026 if (it != m_roleMapping.end()) 0027 return QIdentityProxyModel::data(index, it.value()); 0028 return QIdentityProxyModel::data(index, role); 0029 } 0030 0031 #include "moc_rolemappingproxymodel.cpp"