diff --git a/src/core/device.cpp b/src/core/device.cpp index 7b4904e..ef6c2c1 100644 --- a/src/core/device.cpp +++ b/src/core/device.cpp @@ -46,6 +46,26 @@ Device::Device(const QString& name, { } +/** Copy constructor for Device. + * @param other the other Device. + */ +Device::Device(const Device& other) + : QObject() + , m_Name(other.m_Name) + , m_DeviceNode(other.m_DeviceNode) + , m_LogicalSize(other.m_LogicalSize) + , m_TotalLogical(other.m_TotalLogical) + , m_PartitionTable(nullptr) + , m_IconName(other.m_IconName) + , m_SmartStatus(nullptr) + , m_Type(other.m_Type) +{ + if (other.m_PartitionTable) + m_PartitionTable = new PartitionTable(*other.m_PartitionTable); + if (other.m_SmartStatus) + m_SmartStatus = new SmartStatus(*other.m_SmartStatus); +} + /** Destructs a Device. */ Device::~Device() { diff --git a/src/core/device.h b/src/core/device.h index e4453c7..03a57f8 100644 --- a/src/core/device.h +++ b/src/core/device.h @@ -40,7 +40,7 @@ class SmartStatus; */ class LIBKPMCORE_EXPORT Device : public QObject { - Q_DISABLE_COPY(Device) + Device &operator=(const Device &) = delete; friend class CreatePartitionTableOperation; friend class CoreBackend; @@ -54,7 +54,8 @@ public: }; protected: - Device(const QString& name, const QString& deviceNode, const qint32 logicalSize, const qint64 totalLogical, const QString& iconName = QString(), Device::Type type = Device::Disk_Device); + explicit Device(const QString& name, const QString& deviceNode, const qint32 logicalSize, const qint64 totalLogical, const QString& iconName = QString(), Device::Type type = Device::Disk_Device); + explicit Device(const Device& other); public: virtual ~Device();