Turn all extra PartitionInfo fields into QObject properties of Partition
This commit is contained in:
parent
9c05ecef4d
commit
ff5667cb73
@ -139,8 +139,8 @@ CreatePartitionDialog::createPartitionInfo()
|
|||||||
);
|
);
|
||||||
|
|
||||||
auto info = new PartitionInfo( partition );
|
auto info = new PartitionInfo( partition );
|
||||||
info->mountPoint = m_ui->mountPointComboBox->currentText();
|
PartitionInfo::setMountPoint( partition, m_ui->mountPointComboBox->currentText() );
|
||||||
info->format = true;
|
PartitionInfo::setFormat( partition, true );
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ CreatePartitionDialog::initFromPartitionInfo( PartitionInfo* partitionInfo )
|
|||||||
m_ui->fsComboBox->setCurrentText( FileSystem::nameForType( fsType ) );
|
m_ui->fsComboBox->setCurrentText( FileSystem::nameForType( fsType ) );
|
||||||
|
|
||||||
// Mount point
|
// Mount point
|
||||||
m_ui->mountPointComboBox->setCurrentText( partitionInfo->mountPoint );
|
m_ui->mountPointComboBox->setCurrentText( PartitionInfo::mountPoint( partition ) );
|
||||||
|
|
||||||
updateMountPointUi();
|
updateMountPointUi();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ PartitionCoreModule::DeviceInfo::hasRootMountPoint() const
|
|||||||
{
|
{
|
||||||
for ( auto info : m_partitionInfoHash )
|
for ( auto info : m_partitionInfoHash )
|
||||||
{
|
{
|
||||||
if ( info->mountPoint == "/" )
|
if ( PartitionInfo::mountPoint( info->partition ) == "/" )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -17,6 +17,39 @@
|
|||||||
*/
|
*/
|
||||||
#include <PartitionInfo.h>
|
#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 )
|
PartitionInfo::PartitionInfo( Partition* p )
|
||||||
: 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* );
|
explicit PartitionInfo( Partition* );
|
||||||
Partition* 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 */
|
#endif /* PARTITIONINFO_H */
|
||||||
|
@ -100,10 +100,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const
|
|||||||
if ( col == FileSystemColumn )
|
if ( col == FileSystemColumn )
|
||||||
return partition->fileSystem().name();
|
return partition->fileSystem().name();
|
||||||
if ( col == MountPointColumn )
|
if ( col == MountPointColumn )
|
||||||
{
|
return PartitionInfo::mountPoint( partition );
|
||||||
PartitionInfo* info = m_infoProvider->infoForPartition( partition );
|
|
||||||
return info ? info->mountPoint : QString();
|
|
||||||
}
|
|
||||||
if ( col == SizeColumn )
|
if ( col == SizeColumn )
|
||||||
{
|
{
|
||||||
qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();
|
qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();
|
||||||
|
Loading…
Reference in New Issue
Block a user