File indexing completed on 2025-01-05 04:35:35
0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0002 // SPDX-FileCopyrightText: 2020-2022 Harald Sitter <sitter@kde.org> 0003 0004 #include "aceobject.h" 0005 0006 #include <QMetaEnum> 0007 0008 #include <KLocalizedString> 0009 0010 static int flagsToInheritance(uint8_t flags) 0011 { 0012 const auto inheritanceEnum = QMetaEnum::fromType<ACEObject::Inheritance>(); 0013 for (int i = 0; i < inheritanceEnum.keyCount(); ++i) { 0014 const int value = inheritanceEnum.value(i); 0015 if ((flags & value) == value) { 0016 return value; 0017 } 0018 } 0019 return static_cast<int>(ACEObject::Inheritance::None); 0020 } 0021 0022 ACEObject::ACEObject(const std::shared_ptr<ACE> &ace, QObject *parent) 0023 : QObject(parent) 0024 , m_ace(ace) 0025 , m_inherited(ace->flags & INHERITED_ACE) 0026 { 0027 } 0028 0029 unsigned int ACEObject::type() const 0030 { 0031 return m_ace->type; 0032 } 0033 0034 void ACEObject::setType(unsigned int type) 0035 { 0036 m_ace->type = type; 0037 Q_ASSERT(m_ace->type == type); 0038 Q_EMIT typeChanged(); 0039 } 0040 0041 int ACEObject::inheritance() const 0042 { 0043 return flagsToInheritance(m_ace->flags); 0044 } 0045 0046 void ACEObject::setInheritance(int intInheritance) 0047 { 0048 m_ace->flags = (m_ace->flags ^ inheritance()) | intInheritance; 0049 Q_EMIT inheritanceChanged(); 0050 } 0051 0052 bool ACEObject::noPropagate() const 0053 { 0054 return m_ace->flags & NO_PROPAGATE_INHERIT_ACE; 0055 } 0056 0057 void ACEObject::setNoPropagate(bool noPropagate) 0058 { 0059 m_ace->flags = noPropagate ? (m_ace->flags | NO_PROPAGATE_INHERIT_ACE) : (m_ace->flags ^ NO_PROPAGATE_INHERIT_ACE); 0060 Q_EMIT noPropagateChanged(); 0061 }