File indexing completed on 2024-05-05 05:48:52
0001 /* 0002 SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2014-2016 Andrius Štikonas <andrius@stikonas.eu> 0004 SPDX-FileCopyrightText: 2015 Chris Campbell <c.j.campbell@ed.ac.uk> 0005 0006 SPDX-License-Identifier: GPL-3.0-or-later 0007 */ 0008 0009 #ifndef KPMCORE_SETPARTFLAGSOPERATION_H 0010 #define KPMCORE_SETPARTFLAGSOPERATION_H 0011 0012 #include "util/libpartitionmanagerexport.h" 0013 0014 #include "ops/operation.h" 0015 0016 #include "core/partitiontable.h" 0017 0018 #include <QString> 0019 0020 class Device; 0021 class OperationStack; 0022 class Partition; 0023 0024 class SetPartFlagsJob; 0025 0026 /** Set Partition flags. 0027 0028 Sets the Partition flags for the given Partition on the given Device. 0029 0030 @author Volker Lanz <vl@fidra.de> 0031 */ 0032 class LIBKPMCORE_EXPORT SetPartFlagsOperation : public Operation 0033 { 0034 friend class OperationStack; 0035 0036 Q_DISABLE_COPY(SetPartFlagsOperation) 0037 0038 public: 0039 SetPartFlagsOperation(Device& d, Partition& p, const PartitionTable::Flags& flags); 0040 0041 public: 0042 QString iconName() const override { 0043 return QStringLiteral("flag-blue"); 0044 } 0045 QString description() const override; 0046 void preview() override; 0047 void undo() override; 0048 0049 bool targets(const Device& d) const override; 0050 bool targets(const Partition& p) const override; 0051 0052 protected: 0053 Partition& flagPartition() { 0054 return m_FlagPartition; 0055 } 0056 const Partition& flagPartition() const { 0057 return m_FlagPartition; 0058 } 0059 0060 Device& targetDevice() { 0061 return m_TargetDevice; 0062 } 0063 const Device& targetDevice() const { 0064 return m_TargetDevice; 0065 } 0066 0067 const PartitionTable::Flags& oldFlags() const { 0068 return m_OldFlags; 0069 } 0070 const PartitionTable::Flags& newFlags() const { 0071 return m_NewFlags; 0072 } 0073 0074 void setOldFlags(PartitionTable::Flags f) { 0075 m_OldFlags = f; 0076 } 0077 0078 SetPartFlagsJob* flagsJob() { 0079 return m_FlagsJob; 0080 } 0081 0082 private: 0083 Device& m_TargetDevice; 0084 Partition& m_FlagPartition; 0085 PartitionTable::Flags m_OldFlags; 0086 PartitionTable::Flags m_NewFlags; 0087 SetPartFlagsJob* m_FlagsJob; 0088 }; 0089 0090 #endif