2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2014-06-27 17:25:39 +02:00
|
|
|
*
|
2020-08-22 01:19:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2014 Aurélien Gâteau <agateau@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2015-2016 Teo Mrnjavac <teo@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2018-2019 Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2018 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
* SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
|
|
|
|
* SPDX-FileCopyrightText: 2019 Collabora Ltd
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2014-06-27 17:25:39 +02:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2014-06-27 17:25:39 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PartitionPage.h"
|
|
|
|
|
|
|
|
// Local
|
2015-07-02 13:49:21 +02:00
|
|
|
#include "core/BootLoaderModel.h"
|
|
|
|
#include "core/DeviceModel.h"
|
2020-08-22 01:19:58 +02:00
|
|
|
#include "core/KPMHelpers.h"
|
|
|
|
#include "core/PartUtils.h"
|
2015-07-02 13:49:21 +02:00
|
|
|
#include "core/PartitionCoreModule.h"
|
2016-11-20 23:46:28 +01:00
|
|
|
#include "core/PartitionInfo.h"
|
2015-07-02 13:49:21 +02:00
|
|
|
#include "core/PartitionModel.h"
|
|
|
|
#include "gui/CreatePartitionDialog.h"
|
2018-06-07 22:22:22 +02:00
|
|
|
#include "gui/CreateVolumeGroupDialog.h"
|
2015-07-02 13:49:21 +02:00
|
|
|
#include "gui/EditExistingPartitionDialog.h"
|
2018-06-26 05:38:52 +02:00
|
|
|
#include "gui/ResizeVolumeGroupDialog.h"
|
2015-12-30 16:37:57 +01:00
|
|
|
#include "gui/ScanningDialog.h"
|
2014-08-08 13:25:56 +02:00
|
|
|
|
2015-07-02 13:49:21 +02:00
|
|
|
#include "ui_CreatePartitionTableDialog.h"
|
2020-08-22 01:19:58 +02:00
|
|
|
#include "ui_PartitionPage.h"
|
2014-07-10 19:55:16 +02:00
|
|
|
|
2019-06-13 14:41:33 +02:00
|
|
|
#include "GlobalStorage.h"
|
|
|
|
#include "JobQueue.h"
|
|
|
|
#include "partition/PartitionQuery.h"
|
2018-05-16 16:56:06 +02:00
|
|
|
#include "utils/Logger.h"
|
2014-11-11 17:09:33 +01:00
|
|
|
#include "utils/Retranslator.h"
|
2019-06-13 14:41:33 +02:00
|
|
|
|
2015-12-31 13:56:19 +01:00
|
|
|
#include "Branding.h"
|
2014-11-11 17:09:33 +01:00
|
|
|
|
2015-07-02 13:49:21 +02:00
|
|
|
// KPMcore
|
|
|
|
#include <kpmcore/core/device.h>
|
|
|
|
#include <kpmcore/core/partition.h>
|
2019-04-12 11:21:18 +02:00
|
|
|
#ifdef WITH_KPMCORE4API
|
2018-08-13 14:51:35 +02:00
|
|
|
#include <kpmcore/core/softwareraid.h>
|
2018-09-21 22:19:05 +02:00
|
|
|
#endif
|
2018-06-26 05:38:52 +02:00
|
|
|
#include <kpmcore/ops/deactivatevolumegroupoperation.h>
|
|
|
|
#include <kpmcore/ops/removevolumegroupoperation.h>
|
2015-07-02 13:49:21 +02:00
|
|
|
|
2014-06-27 17:25:39 +02:00
|
|
|
// Qt
|
2020-08-22 01:19:58 +02:00
|
|
|
#include <QDir>
|
|
|
|
#include <QFutureWatcher>
|
2014-07-02 17:55:53 +02:00
|
|
|
#include <QHeaderView>
|
2014-06-27 17:42:13 +02:00
|
|
|
#include <QItemSelectionModel>
|
2014-07-10 19:55:16 +02:00
|
|
|
#include <QMessageBox>
|
2014-07-01 16:46:33 +02:00
|
|
|
#include <QPointer>
|
2015-12-30 16:37:57 +01:00
|
|
|
#include <QtConcurrent/QtConcurrent>
|
2014-06-27 17:25:39 +02:00
|
|
|
|
2014-07-02 16:06:54 +02:00
|
|
|
PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
|
2014-07-03 18:00:40 +02:00
|
|
|
: QWidget( parent )
|
2014-06-27 17:25:39 +02:00
|
|
|
, m_ui( new Ui_PartitionPage )
|
2014-07-02 16:06:54 +02:00
|
|
|
, m_core( core )
|
2020-08-22 01:19:58 +02:00
|
|
|
, m_lastSelectedBootLoaderIndex( -1 )
|
2017-01-18 12:10:50 +01:00
|
|
|
, m_isEfi( false )
|
2014-06-27 17:25:39 +02:00
|
|
|
{
|
2017-08-28 11:36:21 +02:00
|
|
|
m_isEfi = PartUtils::isEfiSystem();
|
2017-01-18 12:10:50 +01:00
|
|
|
|
2014-06-27 17:25:39 +02:00
|
|
|
m_ui->setupUi( this );
|
2016-06-23 10:01:13 +02:00
|
|
|
m_ui->partitionLabelsView->setVisible(
|
2020-08-22 01:19:58 +02:00
|
|
|
Calamares::JobQueue::instance()->globalStorage()->value( "alwaysShowPartitionLabels" ).toBool() );
|
2014-07-21 16:15:53 +02:00
|
|
|
m_ui->deviceComboBox->setModel( m_core->deviceModel() );
|
2014-07-22 10:42:50 +02:00
|
|
|
m_ui->bootLoaderComboBox->setModel( m_core->bootLoaderModel() );
|
2020-08-22 01:19:58 +02:00
|
|
|
connect(
|
|
|
|
m_core->bootLoaderModel(), &QAbstractItemModel::modelReset, this, &PartitionPage::restoreSelectedBootLoader );
|
|
|
|
PartitionBarsView::NestedPartitionsMode mode
|
|
|
|
= Calamares::JobQueue::instance()->globalStorage()->value( "drawNestedPartitions" ).toBool()
|
|
|
|
? PartitionBarsView::DrawNestedPartitions
|
|
|
|
: PartitionBarsView::NoNestedPartitions;
|
2016-02-10 14:59:37 +01:00
|
|
|
m_ui->partitionBarsView->setNestedPartitionsMode( mode );
|
2014-06-30 15:04:10 +02:00
|
|
|
updateButtons();
|
2014-07-23 18:15:46 +02:00
|
|
|
updateBootLoaderInstallPath();
|
2014-06-27 17:25:39 +02:00
|
|
|
|
2014-07-24 19:26:19 +02:00
|
|
|
updateFromCurrentDevice();
|
|
|
|
|
2019-02-26 13:05:32 +01:00
|
|
|
connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged, this, &PartitionPage::updateFromCurrentDevice );
|
2020-08-22 01:19:58 +02:00
|
|
|
connect( m_ui->bootLoaderComboBox,
|
|
|
|
QOverload< int >::of( &QComboBox::activated ),
|
|
|
|
this,
|
|
|
|
&PartitionPage::updateSelectedBootLoaderIndex );
|
|
|
|
connect(
|
|
|
|
m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged, this, &PartitionPage::updateBootLoaderInstallPath );
|
2014-07-23 18:15:46 +02:00
|
|
|
|
2014-07-24 19:28:53 +02:00
|
|
|
connect( m_core, &PartitionCoreModule::isDirtyChanged, m_ui->revertButton, &QWidget::setEnabled );
|
2014-07-23 18:15:46 +02:00
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
connect(
|
|
|
|
m_ui->partitionTreeView, &QAbstractItemView::doubleClicked, this, &PartitionPage::onPartitionViewActivated );
|
2014-07-24 19:28:53 +02:00
|
|
|
connect( m_ui->revertButton, &QAbstractButton::clicked, this, &PartitionPage::onRevertClicked );
|
2018-06-04 21:31:58 +02:00
|
|
|
connect( m_ui->newVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onNewVolumeGroupClicked );
|
2020-08-22 01:19:58 +02:00
|
|
|
connect(
|
|
|
|
m_ui->resizeVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onResizeVolumeGroupClicked );
|
|
|
|
connect( m_ui->deactivateVolumeGroupButton,
|
|
|
|
&QAbstractButton::clicked,
|
|
|
|
this,
|
|
|
|
&PartitionPage::onDeactivateVolumeGroupClicked );
|
|
|
|
connect(
|
|
|
|
m_ui->removeVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onRemoveVolumeGroupClicked );
|
|
|
|
connect(
|
|
|
|
m_ui->newPartitionTableButton, &QAbstractButton::clicked, this, &PartitionPage::onNewPartitionTableClicked );
|
2014-06-30 16:17:28 +02:00
|
|
|
connect( m_ui->createButton, &QAbstractButton::clicked, this, &PartitionPage::onCreateClicked );
|
2014-07-15 17:37:04 +02:00
|
|
|
connect( m_ui->editButton, &QAbstractButton::clicked, this, &PartitionPage::onEditClicked );
|
2014-07-02 15:49:35 +02:00
|
|
|
connect( m_ui->deleteButton, &QAbstractButton::clicked, this, &PartitionPage::onDeleteClicked );
|
2014-11-11 17:09:33 +01:00
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
if ( m_isEfi )
|
|
|
|
{
|
2016-03-09 12:54:16 +01:00
|
|
|
m_ui->bootLoaderComboBox->hide();
|
|
|
|
m_ui->label_3->hide();
|
2015-03-29 16:55:25 +02:00
|
|
|
}
|
2016-05-05 15:28:35 +02:00
|
|
|
|
2014-11-11 17:09:33 +01:00
|
|
|
CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); )
|
2014-06-27 17:25:39 +02:00
|
|
|
}
|
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
PartitionPage::~PartitionPage() {}
|
2014-06-30 15:04:10 +02:00
|
|
|
|
2014-07-02 14:12:47 +02:00
|
|
|
void
|
|
|
|
PartitionPage::updateButtons()
|
2014-06-30 15:04:10 +02:00
|
|
|
{
|
2020-08-22 01:19:58 +02:00
|
|
|
bool create = false, createTable = false, edit = false, del = false, currentDeviceIsVG = false,
|
|
|
|
isDeactivable = false;
|
2018-06-26 05:38:52 +02:00
|
|
|
bool isRemovable = false, isVGdeactivated = false;
|
2014-06-30 15:04:10 +02:00
|
|
|
|
2014-07-02 17:55:53 +02:00
|
|
|
QModelIndex index = m_ui->partitionTreeView->currentIndex();
|
2014-06-30 15:04:10 +02:00
|
|
|
if ( index.isValid() )
|
|
|
|
{
|
|
|
|
const PartitionModel* model = static_cast< const PartitionModel* >( index.model() );
|
|
|
|
Q_ASSERT( model );
|
|
|
|
Partition* partition = model->partitionForIndex( index );
|
|
|
|
Q_ASSERT( partition );
|
2019-06-13 14:41:33 +02:00
|
|
|
bool isFree = CalamaresUtils::Partition::isPartitionFreeSpace( partition );
|
2014-07-16 10:59:24 +02:00
|
|
|
bool isExtended = partition->roles().has( PartitionRole::Extended );
|
|
|
|
|
2018-06-07 22:22:22 +02:00
|
|
|
bool isInVG = m_core->isInVG( partition );
|
|
|
|
|
2014-06-30 15:04:10 +02:00
|
|
|
create = isFree;
|
2018-08-13 14:51:35 +02:00
|
|
|
|
2014-07-16 10:59:24 +02:00
|
|
|
// Keep it simple for now: do not support editing extended partitions as
|
|
|
|
// it does not work with our current edit implementation which is
|
|
|
|
// actually remove + add. This would not work with extended partitions
|
|
|
|
// because they need to be created *before* creating logical partitions
|
|
|
|
// inside them, so an edit must be applied without altering the job
|
|
|
|
// order.
|
2018-06-07 22:22:22 +02:00
|
|
|
// TODO: See if LVM PVs can be edited in Calamares
|
2014-07-16 10:59:24 +02:00
|
|
|
edit = !isFree && !isExtended;
|
2018-06-07 22:22:22 +02:00
|
|
|
del = !isFree && !isInVG;
|
2014-06-30 15:04:10 +02:00
|
|
|
}
|
2016-09-05 11:05:16 +02:00
|
|
|
|
|
|
|
if ( m_ui->deviceComboBox->currentIndex() >= 0 )
|
|
|
|
{
|
2019-02-11 23:45:23 +01:00
|
|
|
Device* device = nullptr;
|
2016-09-05 11:05:16 +02:00
|
|
|
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
|
2019-02-11 23:45:23 +01:00
|
|
|
if ( deviceIndex.isValid() )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2019-02-11 23:45:23 +01:00
|
|
|
device = m_core->deviceModel()->deviceForIndex( deviceIndex );
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2019-02-11 23:45:23 +01:00
|
|
|
if ( !device )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2019-02-11 23:45:23 +01:00
|
|
|
cWarning() << "Device for updateButtons is nullptr";
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2019-02-11 23:45:23 +01:00
|
|
|
else if ( device->type() != Device::Type::LVM_Device )
|
2018-08-13 14:51:35 +02:00
|
|
|
{
|
2016-09-05 11:05:16 +02:00
|
|
|
createTable = true;
|
2018-08-13 14:51:35 +02:00
|
|
|
|
2019-04-12 11:21:18 +02:00
|
|
|
#ifdef WITH_KPMCORE4API
|
2020-08-22 01:19:58 +02:00
|
|
|
if ( device->type() == Device::Type::SoftwareRAID_Device
|
|
|
|
&& static_cast< SoftwareRAID* >( device )->status() == SoftwareRAID::Status::Inactive )
|
2018-09-21 22:19:05 +02:00
|
|
|
{
|
2018-08-13 14:51:35 +02:00
|
|
|
createTable = false;
|
|
|
|
create = false;
|
|
|
|
}
|
2018-09-21 22:19:05 +02:00
|
|
|
#endif
|
2018-08-13 14:51:35 +02:00
|
|
|
}
|
2018-06-26 05:38:52 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
currentDeviceIsVG = true;
|
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
LvmDevice* lvmDevice = dynamic_cast< LvmDevice* >( m_core->deviceModel()->deviceForIndex( deviceIndex ) );
|
2018-06-26 05:38:52 +02:00
|
|
|
|
|
|
|
isDeactivable = DeactivateVolumeGroupOperation::isDeactivatable( lvmDevice );
|
|
|
|
isRemovable = RemoveVolumeGroupOperation::isRemovable( lvmDevice );
|
|
|
|
|
|
|
|
isVGdeactivated = m_core->isVGdeactivated( lvmDevice );
|
|
|
|
|
2018-06-26 06:29:57 +02:00
|
|
|
if ( isVGdeactivated )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2018-06-26 06:29:57 +02:00
|
|
|
m_ui->revertButton->setEnabled( true );
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2018-06-26 05:38:52 +02:00
|
|
|
}
|
2016-09-05 11:05:16 +02:00
|
|
|
}
|
|
|
|
|
2014-06-30 15:04:10 +02:00
|
|
|
m_ui->createButton->setEnabled( create );
|
|
|
|
m_ui->editButton->setEnabled( edit );
|
|
|
|
m_ui->deleteButton->setEnabled( del );
|
2016-09-05 11:05:16 +02:00
|
|
|
m_ui->newPartitionTableButton->setEnabled( createTable );
|
2018-06-26 05:38:52 +02:00
|
|
|
m_ui->resizeVolumeGroupButton->setEnabled( currentDeviceIsVG && !isVGdeactivated );
|
|
|
|
m_ui->deactivateVolumeGroupButton->setEnabled( currentDeviceIsVG && isDeactivable && !isVGdeactivated );
|
|
|
|
m_ui->removeVolumeGroupButton->setEnabled( currentDeviceIsVG && isRemovable );
|
2014-07-10 19:55:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PartitionPage::onNewPartitionTableClicked()
|
|
|
|
{
|
2014-07-29 15:54:48 +02:00
|
|
|
QModelIndex index = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
|
2014-07-10 19:55:16 +02:00
|
|
|
Q_ASSERT( index.isValid() );
|
|
|
|
Device* device = m_core->deviceModel()->deviceForIndex( index );
|
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
QPointer< QDialog > dlg = new QDialog( this );
|
2014-07-15 14:40:08 +02:00
|
|
|
Ui_CreatePartitionTableDialog ui;
|
|
|
|
ui.setupUi( dlg.data() );
|
|
|
|
QString areYouSure = tr( "Are you sure you want to create a new partition table on %1?" ).arg( device->name() );
|
2019-04-25 14:40:27 +02:00
|
|
|
if ( PartUtils::isEfiSystem() )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2019-04-25 14:40:27 +02:00
|
|
|
ui.gptRadioButton->setChecked( true );
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2019-04-25 14:40:27 +02:00
|
|
|
else
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2019-04-25 14:40:27 +02:00
|
|
|
ui.mbrRadioButton->setChecked( true );
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2019-04-25 14:40:27 +02:00
|
|
|
|
2014-07-15 14:40:08 +02:00
|
|
|
ui.areYouSureLabel->setText( areYouSure );
|
|
|
|
if ( dlg->exec() == QDialog::Accepted )
|
|
|
|
{
|
|
|
|
PartitionTable::TableType type = ui.mbrRadioButton->isChecked() ? PartitionTable::msdos : PartitionTable::gpt;
|
|
|
|
m_core->createPartitionTable( device, type );
|
|
|
|
}
|
|
|
|
delete dlg;
|
2019-05-28 16:47:09 +02:00
|
|
|
// PartionModelReset isn't emitted after createPartitionTable, so we have to manually update
|
2016-05-05 15:28:35 +02:00
|
|
|
// the bootLoader index after the reset.
|
|
|
|
updateBootLoaderIndex();
|
2014-06-30 15:04:10 +02:00
|
|
|
}
|
2014-06-30 16:17:28 +02:00
|
|
|
|
2018-05-16 16:56:06 +02:00
|
|
|
bool
|
|
|
|
PartitionPage::checkCanCreate( Device* device )
|
|
|
|
{
|
|
|
|
auto table = device->partitionTable();
|
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
if ( table->type() == PartitionTable::msdos || table->type() == PartitionTable::msdos_sectorbased )
|
2018-05-16 16:56:06 +02:00
|
|
|
{
|
|
|
|
cDebug() << "Checking MSDOS partition" << table->numPrimaries() << "primaries, max" << table->maxPrimaries();
|
|
|
|
|
|
|
|
if ( ( table->numPrimaries() >= table->maxPrimaries() ) && !table->hasExtended() )
|
|
|
|
{
|
2020-08-22 01:19:58 +02:00
|
|
|
QMessageBox::warning(
|
|
|
|
this,
|
|
|
|
tr( "Can not create new partition" ),
|
2018-05-16 16:56:06 +02:00
|
|
|
tr( "The partition table on %1 already has %2 primary partitions, and no more can be added. "
|
2020-08-22 01:19:58 +02:00
|
|
|
"Please remove one primary partition and add an extended partition, instead." )
|
|
|
|
.arg( device->name() )
|
|
|
|
.arg( table->numPrimaries() ) );
|
2018-05-16 16:56:06 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2018-05-16 16:56:06 +02:00
|
|
|
return true; // GPT is fine
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2018-05-16 16:56:06 +02:00
|
|
|
}
|
|
|
|
|
2018-06-04 21:31:58 +02:00
|
|
|
void
|
|
|
|
PartitionPage::onNewVolumeGroupClicked()
|
|
|
|
{
|
|
|
|
QString vgName;
|
2018-06-07 22:22:22 +02:00
|
|
|
QVector< const Partition* > selectedPVs;
|
2018-06-26 05:38:52 +02:00
|
|
|
qint64 peSize = 4;
|
2018-06-04 21:31:58 +02:00
|
|
|
|
2018-06-07 22:22:22 +02:00
|
|
|
QVector< const Partition* > availablePVs;
|
|
|
|
|
|
|
|
for ( const Partition* p : m_core->lvmPVs() )
|
|
|
|
if ( !m_core->isInVG( p ) )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2018-06-07 22:22:22 +02:00
|
|
|
availablePVs << p;
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2018-06-07 22:22:22 +02:00
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
QPointer< CreateVolumeGroupDialog > dlg
|
|
|
|
= new CreateVolumeGroupDialog( vgName, selectedPVs, availablePVs, peSize, this );
|
2018-06-04 21:31:58 +02:00
|
|
|
|
|
|
|
if ( dlg->exec() == QDialog::Accepted )
|
|
|
|
{
|
2018-06-07 22:22:22 +02:00
|
|
|
QModelIndex partitionIndex = m_ui->partitionTreeView->currentIndex();
|
|
|
|
|
|
|
|
if ( partitionIndex.isValid() )
|
|
|
|
{
|
|
|
|
const PartitionModel* model = static_cast< const PartitionModel* >( partitionIndex.model() );
|
|
|
|
Q_ASSERT( model );
|
|
|
|
Partition* partition = model->partitionForIndex( partitionIndex );
|
|
|
|
Q_ASSERT( partition );
|
|
|
|
|
|
|
|
// Disable delete button if current partition was selected to be in VG
|
|
|
|
// TODO: Should Calamares edit LVM PVs which are in VGs?
|
|
|
|
if ( selectedPVs.contains( partition ) )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2018-06-07 22:22:22 +02:00
|
|
|
m_ui->deleteButton->setEnabled( false );
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2018-06-07 22:22:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
|
|
|
|
Q_ASSERT( deviceIndex.isValid() );
|
|
|
|
|
2018-06-09 01:20:05 +02:00
|
|
|
QVariant previousIndexDeviceData = m_core->deviceModel()->data( deviceIndex, Qt::ToolTipRole );
|
2018-06-07 22:22:22 +02:00
|
|
|
|
2018-06-09 01:20:05 +02:00
|
|
|
// Creating new VG
|
2018-06-07 22:22:22 +02:00
|
|
|
m_core->createVolumeGroup( vgName, selectedPVs, peSize );
|
|
|
|
|
|
|
|
// As createVolumeGroup method call resets deviceModel,
|
|
|
|
// is needed to set the current index in deviceComboBox as the previous one
|
2018-06-09 01:20:05 +02:00
|
|
|
int previousIndex = m_ui->deviceComboBox->findData( previousIndexDeviceData, Qt::ToolTipRole );
|
2018-06-04 21:31:58 +02:00
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
m_ui->deviceComboBox->setCurrentIndex( ( previousIndex < 0 ) ? 0 : previousIndex );
|
2018-06-09 01:20:05 +02:00
|
|
|
updateFromCurrentDevice();
|
2018-06-04 21:31:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
delete dlg;
|
|
|
|
}
|
|
|
|
|
2018-06-26 05:38:52 +02:00
|
|
|
void
|
|
|
|
PartitionPage::onResizeVolumeGroupClicked()
|
|
|
|
{
|
|
|
|
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
|
|
|
|
LvmDevice* device = dynamic_cast< LvmDevice* >( m_core->deviceModel()->deviceForIndex( deviceIndex ) );
|
|
|
|
|
|
|
|
Q_ASSERT( device && device->type() == Device::Type::LVM_Device );
|
|
|
|
|
|
|
|
QVector< const Partition* > availablePVs;
|
|
|
|
QVector< const Partition* > selectedPVs;
|
|
|
|
|
|
|
|
for ( const Partition* p : m_core->lvmPVs() )
|
|
|
|
if ( !m_core->isInVG( p ) )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2018-06-26 05:38:52 +02:00
|
|
|
availablePVs << p;
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2018-06-26 05:38:52 +02:00
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
QPointer< ResizeVolumeGroupDialog > dlg = new ResizeVolumeGroupDialog( device, availablePVs, selectedPVs, this );
|
2018-06-26 05:38:52 +02:00
|
|
|
|
|
|
|
if ( dlg->exec() == QDialog::Accepted )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2018-06-26 05:38:52 +02:00
|
|
|
m_core->resizeVolumeGroup( device, selectedPVs );
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2018-06-26 05:38:52 +02:00
|
|
|
|
|
|
|
delete dlg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PartitionPage::onDeactivateVolumeGroupClicked()
|
|
|
|
{
|
|
|
|
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
|
|
|
|
LvmDevice* device = dynamic_cast< LvmDevice* >( m_core->deviceModel()->deviceForIndex( deviceIndex ) );
|
|
|
|
|
|
|
|
Q_ASSERT( device && device->type() == Device::Type::LVM_Device );
|
|
|
|
|
|
|
|
m_core->deactivateVolumeGroup( device );
|
|
|
|
|
|
|
|
updateFromCurrentDevice();
|
|
|
|
|
|
|
|
PartitionModel* model = m_core->partitionModelForDevice( device );
|
|
|
|
model->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PartitionPage::onRemoveVolumeGroupClicked()
|
|
|
|
{
|
|
|
|
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
|
|
|
|
LvmDevice* device = dynamic_cast< LvmDevice* >( m_core->deviceModel()->deviceForIndex( deviceIndex ) );
|
|
|
|
|
|
|
|
Q_ASSERT( device && device->type() == Device::Type::LVM_Device );
|
|
|
|
|
|
|
|
m_core->removeVolumeGroup( device );
|
|
|
|
}
|
|
|
|
|
2014-07-02 14:12:47 +02:00
|
|
|
void
|
|
|
|
PartitionPage::onCreateClicked()
|
2014-06-30 16:17:28 +02:00
|
|
|
{
|
2014-07-02 17:55:53 +02:00
|
|
|
QModelIndex index = m_ui->partitionTreeView->currentIndex();
|
2014-06-30 16:17:28 +02:00
|
|
|
Q_ASSERT( index.isValid() );
|
|
|
|
|
|
|
|
const PartitionModel* model = static_cast< const PartitionModel* >( index.model() );
|
|
|
|
Partition* partition = model->partitionForIndex( index );
|
|
|
|
Q_ASSERT( partition );
|
|
|
|
|
2018-05-16 16:56:06 +02:00
|
|
|
if ( !checkCanCreate( model->device() ) )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2018-05-16 16:56:06 +02:00
|
|
|
return;
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2018-05-16 16:56:06 +02:00
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
CreatePartitionDialog dlg( model->device(), partition->parent(), nullptr, getCurrentUsedMountpoints(), this );
|
2019-02-26 13:21:36 +01:00
|
|
|
dlg.initFromFreeSpace( partition );
|
|
|
|
if ( dlg.exec() == QDialog::Accepted )
|
2016-03-08 12:44:49 +01:00
|
|
|
{
|
2019-02-26 13:21:36 +01:00
|
|
|
Partition* newPart = dlg.createPartition();
|
|
|
|
m_core->createPartition( model->device(), newPart, dlg.newFlags() );
|
2016-03-08 12:44:49 +01:00
|
|
|
}
|
2014-06-30 16:17:28 +02:00
|
|
|
}
|
2014-07-02 15:49:35 +02:00
|
|
|
|
2014-07-15 17:37:04 +02:00
|
|
|
void
|
|
|
|
PartitionPage::onEditClicked()
|
|
|
|
{
|
|
|
|
QModelIndex index = m_ui->partitionTreeView->currentIndex();
|
|
|
|
Q_ASSERT( index.isValid() );
|
|
|
|
|
|
|
|
const PartitionModel* model = static_cast< const PartitionModel* >( index.model() );
|
|
|
|
Partition* partition = model->partitionForIndex( index );
|
|
|
|
Q_ASSERT( partition );
|
|
|
|
|
2019-06-13 14:41:33 +02:00
|
|
|
if ( CalamaresUtils::Partition::isPartitionNew( partition ) )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2014-07-16 16:20:58 +02:00
|
|
|
updatePartitionToCreate( model->device(), partition );
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2014-07-15 17:37:04 +02:00
|
|
|
else
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2014-07-17 09:49:15 +02:00
|
|
|
editExistingPartition( model->device(), partition );
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2014-07-15 17:37:04 +02:00
|
|
|
}
|
|
|
|
|
2014-07-02 15:49:35 +02:00
|
|
|
void
|
|
|
|
PartitionPage::onDeleteClicked()
|
|
|
|
{
|
2014-07-02 17:55:53 +02:00
|
|
|
QModelIndex index = m_ui->partitionTreeView->currentIndex();
|
2014-07-02 15:49:35 +02:00
|
|
|
Q_ASSERT( index.isValid() );
|
|
|
|
|
|
|
|
const PartitionModel* model = static_cast< const PartitionModel* >( index.model() );
|
|
|
|
Partition* partition = model->partitionForIndex( index );
|
|
|
|
Q_ASSERT( partition );
|
|
|
|
|
|
|
|
m_core->deletePartition( model->device(), partition );
|
|
|
|
}
|
2014-07-15 17:37:04 +02:00
|
|
|
|
2015-12-30 16:37:57 +01:00
|
|
|
|
2014-07-24 19:28:53 +02:00
|
|
|
void
|
|
|
|
PartitionPage::onRevertClicked()
|
|
|
|
{
|
2015-12-31 13:56:19 +01:00
|
|
|
ScanningDialog::run(
|
2020-09-29 14:04:12 +02:00
|
|
|
QtConcurrent::run( [ this ] {
|
2015-12-31 13:56:19 +01:00
|
|
|
QMutexLocker locker( &m_revertMutex );
|
|
|
|
|
|
|
|
int oldIndex = m_ui->deviceComboBox->currentIndex();
|
|
|
|
m_core->revertAllDevices();
|
2020-08-22 01:19:58 +02:00
|
|
|
m_ui->deviceComboBox->setCurrentIndex( ( oldIndex < 0 ) ? 0 : oldIndex );
|
2015-12-31 13:56:19 +01:00
|
|
|
updateFromCurrentDevice();
|
|
|
|
} ),
|
2020-09-29 14:04:12 +02:00
|
|
|
[ this ] {
|
2016-05-05 15:28:35 +02:00
|
|
|
m_lastSelectedBootLoaderIndex = -1;
|
2020-08-22 01:19:58 +02:00
|
|
|
if ( m_ui->bootLoaderComboBox->currentIndex() < 0 )
|
|
|
|
{
|
2016-05-05 15:28:35 +02:00
|
|
|
m_ui->bootLoaderComboBox->setCurrentIndex( 0 );
|
|
|
|
}
|
|
|
|
},
|
2015-12-31 13:56:19 +01:00
|
|
|
this );
|
2014-07-24 19:28:53 +02:00
|
|
|
}
|
|
|
|
|
2014-07-25 13:07:22 +02:00
|
|
|
void
|
|
|
|
PartitionPage::onPartitionViewActivated()
|
|
|
|
{
|
|
|
|
QModelIndex index = m_ui->partitionTreeView->currentIndex();
|
|
|
|
if ( !index.isValid() )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2014-07-25 13:07:22 +02:00
|
|
|
return;
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2014-07-25 13:07:22 +02:00
|
|
|
|
|
|
|
const PartitionModel* model = static_cast< const PartitionModel* >( index.model() );
|
|
|
|
Q_ASSERT( model );
|
|
|
|
Partition* partition = model->partitionForIndex( index );
|
|
|
|
Q_ASSERT( partition );
|
|
|
|
|
|
|
|
// Use the buttons to trigger the actions so that they do nothing if they
|
|
|
|
// are disabled. Alternatively, the code could use QAction to centralize,
|
|
|
|
// but I don't expect there will be other occurences of triggering the same
|
|
|
|
// action from multiple UI elements in this page, so it does not feel worth
|
|
|
|
// the price.
|
2019-06-13 14:41:33 +02:00
|
|
|
if ( CalamaresUtils::Partition::isPartitionFreeSpace( partition ) )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2014-07-25 13:07:22 +02:00
|
|
|
m_ui->createButton->click();
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2014-07-25 13:07:22 +02:00
|
|
|
else
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2014-07-25 13:07:22 +02:00
|
|
|
m_ui->editButton->click();
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2014-07-25 13:07:22 +02:00
|
|
|
}
|
|
|
|
|
2014-07-15 17:37:04 +02:00
|
|
|
void
|
2014-07-16 16:20:58 +02:00
|
|
|
PartitionPage::updatePartitionToCreate( Device* device, Partition* partition )
|
2014-07-15 17:37:04 +02:00
|
|
|
{
|
2016-11-21 00:19:33 +01:00
|
|
|
QStringList mountPoints = getCurrentUsedMountpoints();
|
|
|
|
mountPoints.removeOne( PartitionInfo::mountPoint( partition ) );
|
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
QPointer< CreatePartitionDialog > dlg
|
|
|
|
= new CreatePartitionDialog( device, partition->parent(), partition, mountPoints, this );
|
2014-07-16 16:20:58 +02:00
|
|
|
dlg->initFromPartitionToCreate( partition );
|
2014-07-15 17:37:04 +02:00
|
|
|
if ( dlg->exec() == QDialog::Accepted )
|
|
|
|
{
|
2014-08-04 19:23:39 +02:00
|
|
|
Partition* newPartition = dlg->createPartition();
|
2014-07-15 17:37:04 +02:00
|
|
|
m_core->deletePartition( device, partition );
|
2016-03-08 16:26:20 +01:00
|
|
|
m_core->createPartition( device, newPartition, dlg->newFlags() );
|
2014-07-15 17:37:04 +02:00
|
|
|
}
|
|
|
|
delete dlg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-07-17 09:49:15 +02:00
|
|
|
PartitionPage::editExistingPartition( Device* device, Partition* partition )
|
2014-07-15 17:37:04 +02:00
|
|
|
{
|
2016-11-21 00:19:33 +01:00
|
|
|
QStringList mountPoints = getCurrentUsedMountpoints();
|
|
|
|
mountPoints.removeOne( PartitionInfo::mountPoint( partition ) );
|
|
|
|
|
2020-08-22 01:19:58 +02:00
|
|
|
QPointer< EditExistingPartitionDialog > dlg
|
|
|
|
= new EditExistingPartitionDialog( device, partition, mountPoints, this );
|
2014-07-17 09:49:15 +02:00
|
|
|
if ( dlg->exec() == QDialog::Accepted )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2014-07-17 09:49:15 +02:00
|
|
|
dlg->applyChanges( m_core );
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2014-07-17 09:49:15 +02:00
|
|
|
delete dlg;
|
2014-07-15 17:37:04 +02:00
|
|
|
}
|
2014-07-23 18:15:46 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
PartitionPage::updateBootLoaderInstallPath()
|
|
|
|
{
|
2017-01-18 12:10:50 +01:00
|
|
|
if ( m_isEfi || !m_ui->bootLoaderComboBox->isVisible() )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2017-01-18 12:10:50 +01:00
|
|
|
return;
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2017-01-18 12:10:50 +01:00
|
|
|
|
2014-07-23 18:15:46 +02:00
|
|
|
QVariant var = m_ui->bootLoaderComboBox->currentData( BootLoaderModel::BootLoaderPathRole );
|
|
|
|
if ( !var.isValid() )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2014-07-23 18:15:46 +02:00
|
|
|
return;
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2019-02-26 13:10:56 +01:00
|
|
|
cDebug() << "PartitionPage::updateBootLoaderInstallPath" << var.toString();
|
2014-07-23 18:15:46 +02:00
|
|
|
m_core->setBootLoaderInstallPath( var.toString() );
|
|
|
|
}
|
2014-07-24 19:26:19 +02:00
|
|
|
|
2019-02-26 13:05:32 +01:00
|
|
|
void
|
|
|
|
PartitionPage::updateSelectedBootLoaderIndex()
|
|
|
|
{
|
|
|
|
m_lastSelectedBootLoaderIndex = m_ui->bootLoaderComboBox->currentIndex();
|
2019-02-26 13:10:56 +01:00
|
|
|
cDebug() << "Selected bootloader index" << m_lastSelectedBootLoaderIndex;
|
2019-02-26 13:05:32 +01:00
|
|
|
}
|
|
|
|
|
2019-03-29 16:33:40 +01:00
|
|
|
void
|
|
|
|
PartitionPage::restoreSelectedBootLoader()
|
|
|
|
{
|
2020-08-22 01:19:58 +02:00
|
|
|
Calamares::restoreSelectedBootLoader( *( m_ui->bootLoaderComboBox ), m_core->bootLoaderInstallPath() );
|
2019-03-29 16:33:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-24 19:26:19 +02:00
|
|
|
void
|
|
|
|
PartitionPage::updateFromCurrentDevice()
|
|
|
|
{
|
|
|
|
QModelIndex index = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
|
|
|
|
if ( !index.isValid() )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2014-07-24 19:26:19 +02:00
|
|
|
return;
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2014-07-24 19:26:19 +02:00
|
|
|
|
|
|
|
Device* device = m_core->deviceModel()->deviceForIndex( index );
|
|
|
|
|
2014-07-29 10:57:10 +02:00
|
|
|
QAbstractItemModel* oldModel = m_ui->partitionTreeView->model();
|
|
|
|
if ( oldModel )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2019-05-14 10:58:19 +02:00
|
|
|
disconnect( oldModel, nullptr, this, nullptr );
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2014-07-29 10:57:10 +02:00
|
|
|
|
2014-07-24 19:26:19 +02:00
|
|
|
PartitionModel* model = m_core->partitionModelForDevice( device );
|
2015-12-03 17:19:02 +01:00
|
|
|
m_ui->partitionBarsView->setModel( model );
|
2016-06-23 10:01:13 +02:00
|
|
|
m_ui->partitionLabelsView->setModel( model );
|
2014-07-24 19:26:19 +02:00
|
|
|
m_ui->partitionTreeView->setModel( model );
|
2014-07-29 10:57:10 +02:00
|
|
|
m_ui->partitionTreeView->expandAll();
|
2014-07-24 19:26:19 +02:00
|
|
|
|
2016-06-23 10:01:13 +02:00
|
|
|
// Make all views use the same selection model.
|
2020-08-22 01:19:58 +02:00
|
|
|
if ( m_ui->partitionBarsView->selectionModel() != m_ui->partitionTreeView->selectionModel()
|
|
|
|
|| m_ui->partitionBarsView->selectionModel() != m_ui->partitionLabelsView->selectionModel() )
|
2015-12-30 17:25:48 +01:00
|
|
|
{
|
2016-06-23 10:01:13 +02:00
|
|
|
// Tree view
|
2015-12-30 17:25:48 +01:00
|
|
|
QItemSelectionModel* selectionModel = m_ui->partitionTreeView->selectionModel();
|
|
|
|
m_ui->partitionTreeView->setSelectionModel( m_ui->partitionBarsView->selectionModel() );
|
|
|
|
selectionModel->deleteLater();
|
2016-06-23 10:01:13 +02:00
|
|
|
|
|
|
|
// Labels view
|
|
|
|
selectionModel = m_ui->partitionLabelsView->selectionModel();
|
|
|
|
m_ui->partitionLabelsView->setSelectionModel( m_ui->partitionBarsView->selectionModel() );
|
|
|
|
selectionModel->deleteLater();
|
2015-12-30 17:25:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is necessary because even with the same selection model it might happen that
|
|
|
|
// a !=0 column is selected in the tree view, which for some reason doesn't trigger a
|
|
|
|
// timely repaint in the bars view.
|
2020-08-22 01:19:58 +02:00
|
|
|
connect(
|
|
|
|
m_ui->partitionBarsView->selectionModel(),
|
|
|
|
&QItemSelectionModel::currentChanged,
|
|
|
|
this,
|
2020-09-29 14:04:12 +02:00
|
|
|
[ = ] {
|
2020-08-22 01:19:58 +02:00
|
|
|
QModelIndex selectedIndex = m_ui->partitionBarsView->selectionModel()->currentIndex();
|
|
|
|
selectedIndex = selectedIndex.sibling( selectedIndex.row(), 0 );
|
|
|
|
m_ui->partitionBarsView->setCurrentIndex( selectedIndex );
|
|
|
|
m_ui->partitionLabelsView->setCurrentIndex( selectedIndex );
|
|
|
|
},
|
|
|
|
Qt::UniqueConnection );
|
2015-12-30 17:25:48 +01:00
|
|
|
|
2014-07-24 19:26:19 +02:00
|
|
|
// Must be done here because we need to have a model set to define
|
|
|
|
// individual column resize mode
|
|
|
|
QHeaderView* header = m_ui->partitionTreeView->header();
|
|
|
|
header->setSectionResizeMode( QHeaderView::ResizeToContents );
|
|
|
|
header->setSectionResizeMode( 0, QHeaderView::Stretch );
|
|
|
|
|
|
|
|
updateButtons();
|
|
|
|
// Establish connection here because selection model is destroyed when
|
|
|
|
// model changes
|
2020-08-22 01:19:58 +02:00
|
|
|
connect( m_ui->partitionTreeView->selectionModel(),
|
|
|
|
&QItemSelectionModel::currentChanged,
|
2020-09-29 14:04:12 +02:00
|
|
|
[ this ]( const QModelIndex&, const QModelIndex& ) { updateButtons(); } );
|
2014-07-29 10:57:10 +02:00
|
|
|
connect( model, &QAbstractItemModel::modelReset, this, &PartitionPage::onPartitionModelReset );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PartitionPage::onPartitionModelReset()
|
|
|
|
{
|
|
|
|
m_ui->partitionTreeView->expandAll();
|
2019-03-01 12:56:52 +01:00
|
|
|
updateButtons();
|
2016-05-05 15:28:35 +02:00
|
|
|
updateBootLoaderIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PartitionPage::updateBootLoaderIndex()
|
|
|
|
{
|
|
|
|
// set bootloader back to user selected index
|
2020-08-22 01:19:58 +02:00
|
|
|
if ( m_lastSelectedBootLoaderIndex >= 0 && m_ui->bootLoaderComboBox->count() )
|
|
|
|
{
|
2016-05-05 15:28:35 +02:00
|
|
|
m_ui->bootLoaderComboBox->setCurrentIndex( m_lastSelectedBootLoaderIndex );
|
|
|
|
}
|
2014-07-24 19:26:19 +02:00
|
|
|
}
|
2016-11-20 23:05:55 +01:00
|
|
|
|
|
|
|
QStringList
|
|
|
|
PartitionPage::getCurrentUsedMountpoints()
|
|
|
|
{
|
2020-08-22 01:19:58 +02:00
|
|
|
QModelIndex index = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
|
2016-11-20 23:05:55 +01:00
|
|
|
if ( !index.isValid() )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2016-11-20 23:05:55 +01:00
|
|
|
return QStringList();
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2016-11-20 23:05:55 +01:00
|
|
|
|
|
|
|
Device* device = m_core->deviceModel()->deviceForIndex( index );
|
|
|
|
QStringList mountPoints;
|
|
|
|
|
2017-01-04 15:18:26 +01:00
|
|
|
for ( Partition* partition : device->partitionTable()->children() )
|
|
|
|
{
|
2016-11-20 23:46:28 +01:00
|
|
|
const QString& mountPoint = PartitionInfo::mountPoint( partition );
|
2017-01-04 15:18:26 +01:00
|
|
|
if ( !mountPoint.isEmpty() )
|
2020-08-22 01:19:58 +02:00
|
|
|
{
|
2016-11-20 23:46:28 +01:00
|
|
|
mountPoints << mountPoint;
|
2020-08-22 01:19:58 +02:00
|
|
|
}
|
2016-11-20 23:05:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return mountPoints;
|
|
|
|
}
|
2019-01-10 16:28:05 +01:00
|
|
|
|
|
|
|
int
|
|
|
|
PartitionPage::selectedDeviceIndex()
|
|
|
|
{
|
|
|
|
return m_ui->deviceComboBox->currentIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-08-22 01:19:58 +02:00
|
|
|
PartitionPage::selectDeviceByIndex( int index )
|
2019-01-10 16:28:05 +01:00
|
|
|
{
|
2020-08-22 01:19:58 +02:00
|
|
|
m_ui->deviceComboBox->setCurrentIndex( index );
|
2019-01-10 16:28:05 +01:00
|
|
|
}
|