Turn all extra PartitionInfo fields into QObject properties of Partition

main
Aurélien Gâteau 11 years ago
parent 9c05ecef4d
commit ff5667cb73

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

@ -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;

@ -17,6 +17,39 @@
*/
#include <PartitionInfo.h>
// CalaPM
#include <core/partition.h>
// Qt
#include <QVariant>
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 );
}

@ -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 */

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

Loading…
Cancel
Save