From 881bf67d2285f3c3bb8b7339b221169bb09b2983 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Tue, 7 Jul 2015 19:16:22 +0200 Subject: [PATCH] Add a "do not install boot loader" value to the boot loader picker. --- .../partition/core/BootLoaderModel.cpp | 32 +++++++++++++------ .../partition/jobs/FillGlobalStorageJob.cpp | 15 ++++++--- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/modules/partition/core/BootLoaderModel.cpp b/src/modules/partition/core/BootLoaderModel.cpp index ceecb17de..262954e83 100644 --- a/src/modules/partition/core/BootLoaderModel.cpp +++ b/src/modules/partition/core/BootLoaderModel.cpp @@ -66,6 +66,9 @@ BootLoaderModel::createMbrItems() void BootLoaderModel::update() { + clear(); + createMbrItems(); + QString partitionText; Partition* partition = PMUtils::findPartitionByMountPoint( m_devices, "/boot" ); if ( partition ) @@ -86,19 +89,25 @@ BootLoaderModel::update() { if ( lastIsPartition ) takeRow( rowCount() - 1 ); - return; - } - - QString mountPoint = PartitionInfo::mountPoint( partition ); - if ( lastIsPartition ) - { - last->setText( partitionText ); - last->setData( mountPoint, BootLoaderPathRole ); } else { + QString mountPoint = PartitionInfo::mountPoint( partition ); + if ( lastIsPartition ) + { + last->setText( partitionText ); + last->setData( mountPoint, BootLoaderPathRole ); + } + else + { + appendRow( + createBootLoaderItem( partitionText, PartitionInfo::mountPoint( partition ), true ) + ); + } + + // Create "don't install bootloader" item appendRow( - createBootLoaderItem( partitionText, PartitionInfo::mountPoint( partition ), true ) + createBootLoaderItem( tr( "Do not install a boot loader" ), QString(), false ) ); } } @@ -108,9 +117,14 @@ QVariant BootLoaderModel::data( const QModelIndex& index, int role ) const { if ( role == Qt::DisplayRole ) + { + if ( QStandardItemModel::data( index, BootLoaderModel::BootLoaderPathRole ).toString().isEmpty() ) + return QStandardItemModel::data( index, Qt::DisplayRole ).toString(); + return tr( "%1 (%2)" ) .arg( QStandardItemModel::data( index, Qt::DisplayRole ).toString() ) .arg( QStandardItemModel::data( index, BootLoaderModel::BootLoaderPathRole ).toString() ); + } return QStandardItemModel::data( index, role ); } diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index ac577d033..6d8ba8cc4 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -157,10 +157,17 @@ FillGlobalStorageJob::exec() { Calamares::GlobalStorage* storage = Calamares::JobQueue::instance()->globalStorage(); storage->insert( "partitions", createPartitionList() ); - QVariant var = createBootLoaderMap(); - if ( !var.isValid() ) - return Calamares::JobResult::error( tr( "Failed to find path for boot loader" ) ); - storage->insert( "bootLoader", var ); + if ( !m_bootLoaderPath.isEmpty() ) + { + QVariant var = createBootLoaderMap(); + if ( !var.isValid() ) + cDebug() << "Failed to find path for boot loader"; + storage->insert( "bootLoader", var ); + } + else + { + storage->insert( "bootLoader", QVariant() ); + } return Calamares::JobResult::ok(); }