From ff5667cb736a06cc134b00d5a00323af0ddfd017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Wed, 16 Jul 2014 15:50:41 +0200 Subject: [PATCH] Turn all extra PartitionInfo fields into QObject properties of Partition --- .../partition/CreatePartitionDialog.cpp | 6 ++-- src/modules/partition/PartitionCoreModule.cpp | 2 +- src/modules/partition/PartitionInfo.cpp | 33 +++++++++++++++++++ src/modules/partition/PartitionInfo.h | 8 +++-- src/modules/partition/PartitionModel.cpp | 5 +-- 5 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/modules/partition/CreatePartitionDialog.cpp b/src/modules/partition/CreatePartitionDialog.cpp index 72e62f284..6ffb5b8c7 100644 --- a/src/modules/partition/CreatePartitionDialog.cpp +++ b/src/modules/partition/CreatePartitionDialog.cpp @@ -139,8 +139,8 @@ CreatePartitionDialog::createPartitionInfo() ); auto info = new PartitionInfo( partition ); - info->mountPoint = m_ui->mountPointComboBox->currentText(); - info->format = true; + PartitionInfo::setMountPoint( partition, m_ui->mountPointComboBox->currentText() ); + PartitionInfo::setFormat( partition, true ); return info; } @@ -198,7 +198,7 @@ CreatePartitionDialog::initFromPartitionInfo( PartitionInfo* partitionInfo ) m_ui->fsComboBox->setCurrentText( FileSystem::nameForType( fsType ) ); // Mount point - m_ui->mountPointComboBox->setCurrentText( partitionInfo->mountPoint ); + m_ui->mountPointComboBox->setCurrentText( PartitionInfo::mountPoint( partition ) ); updateMountPointUi(); } diff --git a/src/modules/partition/PartitionCoreModule.cpp b/src/modules/partition/PartitionCoreModule.cpp index 58a1ebfe2..8f12b8a91 100644 --- a/src/modules/partition/PartitionCoreModule.cpp +++ b/src/modules/partition/PartitionCoreModule.cpp @@ -73,7 +73,7 @@ PartitionCoreModule::DeviceInfo::hasRootMountPoint() const { for ( auto info : m_partitionInfoHash ) { - if ( info->mountPoint == "/" ) + if ( PartitionInfo::mountPoint( info->partition ) == "/" ) return true; } return false; diff --git a/src/modules/partition/PartitionInfo.cpp b/src/modules/partition/PartitionInfo.cpp index abf61c398..99f5d3281 100644 --- a/src/modules/partition/PartitionInfo.cpp +++ b/src/modules/partition/PartitionInfo.cpp @@ -17,6 +17,39 @@ */ #include +// CalaPM +#include + +// Qt +#include + +static const char* MOUNT_POINT_PROPERTY = "_calamares_mountPoint"; +static const char* FORMAT_PROPERTY = "_calamares_format"; + PartitionInfo::PartitionInfo( Partition* p ) : partition( p ) {} + +QString +PartitionInfo::mountPoint( Partition* partition ) +{ + return partition->property( MOUNT_POINT_PROPERTY ).toString(); +} + +void +PartitionInfo::setMountPoint( Partition* partition, const QString& value ) +{ + partition->setProperty( MOUNT_POINT_PROPERTY, value ); +} + +bool +PartitionInfo::format( Partition* partition ) +{ + return partition->property( FORMAT_PROPERTY ).toBool(); +} + +void +PartitionInfo::setFormat( Partition* partition, bool value ) +{ + partition->setProperty( FORMAT_PROPERTY, value ); +} diff --git a/src/modules/partition/PartitionInfo.h b/src/modules/partition/PartitionInfo.h index 67c8fcd94..1f747dd30 100644 --- a/src/modules/partition/PartitionInfo.h +++ b/src/modules/partition/PartitionInfo.h @@ -31,8 +31,12 @@ struct PartitionInfo { explicit PartitionInfo( Partition* ); Partition* partition; - QString mountPoint; - bool format = false; + + static QString mountPoint( Partition* partition ); + static void setMountPoint( Partition* partition, const QString& value ); + + static bool format( Partition* partition ); + static void setFormat( Partition* partition, bool value ); }; #endif /* PARTITIONINFO_H */ diff --git a/src/modules/partition/PartitionModel.cpp b/src/modules/partition/PartitionModel.cpp index 6c2061fe6..f8b5cc0eb 100644 --- a/src/modules/partition/PartitionModel.cpp +++ b/src/modules/partition/PartitionModel.cpp @@ -100,10 +100,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const if ( col == FileSystemColumn ) return partition->fileSystem().name(); if ( col == MountPointColumn ) - { - PartitionInfo* info = m_infoProvider->infoForPartition( partition ); - return info ? info->mountPoint : QString(); - } + return PartitionInfo::mountPoint( partition ); if ( col == SizeColumn ) { qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();