diff --git a/src/core/partitiontable.cpp b/src/core/partitiontable.cpp index 680f5bb..df68773 100644 --- a/src/core/partitiontable.cpp +++ b/src/core/partitiontable.cpp @@ -39,16 +39,34 @@ /** Creates a new PartitionTable object with type MSDOS @param type name of the PartitionTable type (e.g. "msdos" or "gpt") */ -PartitionTable::PartitionTable(TableType type, qint64 firstUsable, qint64 lastUsable) : - PartitionNode(), - m_Children(), - m_MaxPrimaries(maxPrimariesForTableType(type)), - m_Type(type), - m_FirstUsable(firstUsable), - m_LastUsable(lastUsable) +PartitionTable::PartitionTable(TableType type, qint64 firstUsable, qint64 lastUsable) + : PartitionNode() + , m_Children() + , m_MaxPrimaries(maxPrimariesForTableType(type)) + , m_Type(type) + , m_FirstUsable(firstUsable) + , m_LastUsable(lastUsable) { } +/** Copy constructor for PartitionTable. + * @param other the other PartitionTable. + */ +PartitionTable::PartitionTable(const PartitionTable& other) + : PartitionNode() + , m_Children() + , m_MaxPrimaries(other.m_MaxPrimaries) + , m_Type(other.m_Type) + , m_FirstUsable(other.m_FirstUsable) + , m_LastUsable(other.m_LastUsable) +{ + for (Partitions::const_iterator it = other.m_Children.constBegin(); + it != other.m_Children.constEnd(); ++it) + { + m_Children.append(new Partition(**it)); + } +} + /** Destroys a PartitionTable object, destroying all children */ PartitionTable::~PartitionTable() { diff --git a/src/core/partitiontable.h b/src/core/partitiontable.h index d76cbdc..929fd8e 100644 --- a/src/core/partitiontable.h +++ b/src/core/partitiontable.h @@ -44,7 +44,7 @@ class QTextStream; */ class LIBKPMCORE_EXPORT PartitionTable : public PartitionNode { - Q_DISABLE_COPY(PartitionTable) + PartitionTable &operator=(const PartitionTable &) = delete; friend class CoreBackend; friend LIBKPMCORE_EXPORT QTextStream& operator<<(QTextStream& stream, const PartitionTable& ptable); @@ -96,6 +96,7 @@ public: public: PartitionTable(TableType type, qint64 firstUsable, qint64 lastUsable); + PartitionTable(const PartitionTable& other); ~PartitionTable(); public: