[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kpmcore/copy-device] src/core: Add copy constructor to Device.
From:       Teo Mrnjavac <teo () kde ! org>
Date:       2016-09-07 15:37:54
Message-ID: E1bhevC-0002IQ-H2 () code ! kde ! org
[Download RAW message or body]

Git commit ea9e079ee8cdd8763c63297dd53389e7b5311541 by Teo Mrnjavac.
Committed on 07/09/2016 at 15:35.
Pushed by mrnjavac into branch 'copy-device'.

Add copy constructor to Device.

M  +20   -0    src/core/device.cpp
M  +3    -2    src/core/device.h

http://commits.kde.org/kpmcore/ea9e079ee8cdd8763c63297dd53389e7b5311541

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();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic