Compare commits
15 Commits
calamares
...
issue-1847
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45a47b27bd | ||
|
|
ee5f27b9e0 | ||
|
|
f313a15304 | ||
|
|
042b9d7ade | ||
|
|
c804ba6b23 | ||
|
|
9cffacf148 | ||
|
|
567f5ebc57 | ||
|
|
431dd34404 | ||
|
|
742441152b | ||
|
|
86c037ad12 | ||
|
|
9842fa0162 | ||
|
|
dccc28e4ee | ||
|
|
30bc9f9030 | ||
|
|
e5a6371ef4 | ||
|
|
36e89cff45 |
@@ -20,6 +20,7 @@
|
||||
#include <kpmcore/util/report.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -33,6 +34,8 @@ class PartitionRole;
|
||||
#define KPM_PARTITION_STATE( x ) Partition::State::x
|
||||
#define KPM_PARTITION_FLAG_ESP PartitionTable::Flag::Boot
|
||||
|
||||
using PartitionVector = QVector< const Partition* >;
|
||||
|
||||
/**
|
||||
* Helper functions to manipulate partitions
|
||||
*/
|
||||
|
||||
@@ -377,7 +377,12 @@ PartitionModel*
|
||||
PartitionCoreModule::partitionModelForDevice( const Device* device ) const
|
||||
{
|
||||
DeviceInfo* info = infoForDevice( device );
|
||||
Q_ASSERT( info );
|
||||
if ( !info )
|
||||
{
|
||||
cWarning() << "No DeviceInfo for" << Logger::Pointer( device )
|
||||
<< ( device ? device->deviceNode() : QStringLiteral( "<null>" ) );
|
||||
return nullptr;
|
||||
}
|
||||
return info->partitionModel.data();
|
||||
}
|
||||
|
||||
@@ -428,15 +433,16 @@ PartitionCoreModule::createPartition( Device* device, Partition* partition, Part
|
||||
}
|
||||
|
||||
void
|
||||
PartitionCoreModule::createVolumeGroup( QString& vgName, QVector< const Partition* > pvList, qint32 peSize )
|
||||
PartitionCoreModule::createVolumeGroup( const QString& vgName, const PartitionVector& pvList, qint32 peSize )
|
||||
{
|
||||
QString actualName( vgName );
|
||||
// Appending '_' character in case of repeated VG name
|
||||
while ( hasVGwithThisName( vgName ) )
|
||||
while ( hasVGwithThisName( actualName ) )
|
||||
{
|
||||
vgName.append( '_' );
|
||||
actualName.append( '_' );
|
||||
}
|
||||
|
||||
LvmDevice* device = new LvmDevice( vgName );
|
||||
LvmDevice* device = new LvmDevice( actualName );
|
||||
for ( const Partition* p : pvList )
|
||||
{
|
||||
device->physicalVolumes() << p;
|
||||
@@ -447,12 +453,12 @@ PartitionCoreModule::createVolumeGroup( QString& vgName, QVector< const Partitio
|
||||
m_deviceModel->addDevice( device );
|
||||
m_deviceInfos << deviceInfo;
|
||||
|
||||
deviceInfo->makeJob< CreateVolumeGroupJob >( vgName, pvList, peSize );
|
||||
deviceInfo->makeJob< CreateVolumeGroupJob >( actualName, pvList, peSize );
|
||||
refreshAfterModelChange();
|
||||
}
|
||||
|
||||
void
|
||||
PartitionCoreModule::resizeVolumeGroup( LvmDevice* device, QVector< const Partition* >& pvList )
|
||||
PartitionCoreModule::resizeVolumeGroup( LvmDevice* device, const PartitionVector& pvList )
|
||||
{
|
||||
auto* deviceInfo = infoForDevice( device );
|
||||
Q_ASSERT( deviceInfo );
|
||||
@@ -710,7 +716,7 @@ PartitionCoreModule::efiSystemPartitions() const
|
||||
return m_efiSystemPartitions;
|
||||
}
|
||||
|
||||
QVector< const Partition* >
|
||||
PartitionVector
|
||||
PartitionCoreModule::lvmPVs() const
|
||||
{
|
||||
return m_lvmPVs;
|
||||
|
||||
@@ -138,25 +138,18 @@ public:
|
||||
*/
|
||||
void
|
||||
createPartition( Device* device, Partition* partition, PartitionTable::Flags flags = KPM_PARTITION_FLAG( None ) );
|
||||
void deletePartition( Device* device, Partition* partition );
|
||||
void formatPartition( Device* device, Partition* partition );
|
||||
void resizePartition( Device* device, Partition* partition, qint64 first, qint64 last );
|
||||
void setPartitionFlags( Device* device, Partition* partition, PartitionTable::Flags flags );
|
||||
|
||||
void createVolumeGroup( QString& vgName, QVector< const Partition* > pvList, qint32 peSize );
|
||||
|
||||
void resizeVolumeGroup( LvmDevice* device, QVector< const Partition* >& pvList );
|
||||
|
||||
void createVolumeGroup( const QString& vgName, const PartitionVector& pvList, qint32 peSize );
|
||||
void resizeVolumeGroup( LvmDevice* device, const PartitionVector& pvList );
|
||||
void deactivateVolumeGroup( LvmDevice* device );
|
||||
|
||||
void removeVolumeGroup( LvmDevice* device );
|
||||
|
||||
void deletePartition( Device* device, Partition* partition );
|
||||
|
||||
void formatPartition( Device* device, Partition* partition );
|
||||
|
||||
void setFilesystemLabel( Device* device, Partition* partition, const QString& newLabel );
|
||||
|
||||
void resizePartition( Device* device, Partition* partition, qint64 first, qint64 last );
|
||||
|
||||
void setPartitionFlags( Device* device, Partition* partition, PartitionTable::Flags flags );
|
||||
|
||||
/// @brief Retrieve the path where the bootloader will be installed
|
||||
QString bootLoaderInstallPath() const { return m_bootLoaderInstallPath; }
|
||||
/// @brief Set the path where the bootloader will be installed
|
||||
@@ -195,7 +188,7 @@ public:
|
||||
|
||||
QList< Partition* > efiSystemPartitions() const;
|
||||
|
||||
QVector< const Partition* > lvmPVs() const;
|
||||
PartitionVector lvmPVs() const;
|
||||
|
||||
bool hasVGwithThisName( const QString& name ) const;
|
||||
|
||||
@@ -266,7 +259,7 @@ private:
|
||||
|
||||
QList< DeviceInfo* > m_deviceInfos;
|
||||
QList< Partition* > m_efiSystemPartitions;
|
||||
QVector< const Partition* > m_lvmPVs;
|
||||
PartitionVector m_lvmPVs;
|
||||
|
||||
DeviceModel* m_deviceModel;
|
||||
BootLoaderModel* m_bootLoaderModel;
|
||||
|
||||
@@ -64,19 +64,22 @@ CreatePartitionDialog::CreatePartitionDialog( PartitionCoreModule* core,
|
||||
m_ui->encryptWidget->setText( tr( "En&crypt", "@action" ) );
|
||||
m_ui->encryptWidget->hide();
|
||||
|
||||
if ( m_device->type() != Device::Type::LVM_Device )
|
||||
{
|
||||
m_ui->lvNameLabel->hide();
|
||||
m_ui->lvNameLineEdit->hide();
|
||||
}
|
||||
if ( m_device->type() == Device::Type::LVM_Device )
|
||||
{
|
||||
m_ui->lvNameLabel->show();
|
||||
m_ui->lvNameLineEdit->show();
|
||||
/* LVM logical volume name can consist of: letters numbers _ . - +
|
||||
* It cannot start with underscore _ and must not be equal to . or .. or any entry in /dev/
|
||||
* QLineEdit accepts QValidator::Intermediate, so we just disable . at the beginning */
|
||||
QRegularExpression re( QStringLiteral( R"(^(?!_|\.)[\w\-.+]+)" ) );
|
||||
QRegularExpressionValidator* validator = new QRegularExpressionValidator( re, this );
|
||||
m_ui->lvNameLineEdit->setValidator( validator );
|
||||
connect( m_ui->lvNameLineEdit, &QLineEdit::textChanged, this, &CreatePartitionDialog::updateOkButton );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->lvNameLabel->hide();
|
||||
m_ui->lvNameLineEdit->hide();
|
||||
}
|
||||
|
||||
if ( KPMHelpers::isMSDOSPartition( device->partitionTable()->type() ) )
|
||||
@@ -365,3 +368,13 @@ CreatePartitionDialog::initPartResizerWidget( Partition* partition )
|
||||
m_partitionSizeController->setPartResizerWidget( m_ui->partResizerWidget );
|
||||
m_partitionSizeController->setSpinBox( m_ui->sizeSpinBox );
|
||||
}
|
||||
|
||||
void
|
||||
CreatePartitionDialog::updateOkButton()
|
||||
{
|
||||
if ( m_device->type() == Device::Type::LVM_Device )
|
||||
{
|
||||
QString lvName = m_ui->lvNameLineEdit->text();
|
||||
cDebug() << "LVName" << lvName << m_ui->lvNameLineEdit->hasAcceptableInput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +46,12 @@ private:
|
||||
QWidget* parentWidget );
|
||||
|
||||
public:
|
||||
/// @brief Tag-type for creating partition from free space
|
||||
struct FreeSpace
|
||||
{
|
||||
Partition* p;
|
||||
};
|
||||
/// @brief Tag-type for editing (re-creating) a new partition
|
||||
struct FreshPartition
|
||||
{
|
||||
Partition* p;
|
||||
@@ -84,6 +86,7 @@ public:
|
||||
private Q_SLOTS:
|
||||
void updateMountPointUi();
|
||||
void checkMountPointSelection();
|
||||
void updateOkButton(); // Check if dialog can be accepted
|
||||
|
||||
private:
|
||||
QScopedPointer< Ui_CreatePartitionDialog > m_ui;
|
||||
|
||||
@@ -16,32 +16,13 @@
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
|
||||
CreateVolumeGroupDialog::CreateVolumeGroupDialog( QString& vgName,
|
||||
QVector< const Partition* >& selectedPVs,
|
||||
QVector< const Partition* > pvList,
|
||||
qint64& pSize,
|
||||
CreateVolumeGroupDialog::CreateVolumeGroupDialog( const PartitionVector& pvList,
|
||||
qint32 physicalExtentSize,
|
||||
QWidget* parent )
|
||||
: VolumeGroupBaseDialog( vgName, pvList, parent )
|
||||
, m_selectedPVs( selectedPVs )
|
||||
, m_peSize( pSize )
|
||||
: VolumeGroupBaseDialog( parent, QString(), pvList )
|
||||
{
|
||||
setWindowTitle( tr( "Create Volume Group", "@title" ) );
|
||||
|
||||
peSize()->setValue( pSize );
|
||||
|
||||
vgType()->setEnabled( false );
|
||||
}
|
||||
|
||||
void
|
||||
CreateVolumeGroupDialog::accept()
|
||||
{
|
||||
QString& name = vgNameValue();
|
||||
name = vgName()->text();
|
||||
|
||||
m_selectedPVs << checkedItems();
|
||||
|
||||
qint64& pe = m_peSize;
|
||||
pe = peSize()->value();
|
||||
|
||||
QDialog::accept();
|
||||
peSizeWidget()->setValue( physicalExtentSize );
|
||||
vgTypeWidget()->setEnabled( false );
|
||||
}
|
||||
|
||||
@@ -16,18 +16,7 @@ class CreateVolumeGroupDialog : public VolumeGroupBaseDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CreateVolumeGroupDialog( QString& vgName,
|
||||
QVector< const Partition* >& selectedPVs,
|
||||
QVector< const Partition* > pvList,
|
||||
qint64& pSize,
|
||||
QWidget* parent );
|
||||
|
||||
void accept() override;
|
||||
|
||||
private:
|
||||
QVector< const Partition* >& m_selectedPVs;
|
||||
|
||||
qint64& m_peSize;
|
||||
CreateVolumeGroupDialog( const PartitionVector& pvList, qint32 physicalExtentSize, QWidget* parent );
|
||||
};
|
||||
|
||||
#endif // CREATEVOLUMEGROUPDIALOG_H
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#include <QPointer>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
PartitionPage::PartitionPage( PartitionCoreModule* core, const Config & config, QWidget* parent )
|
||||
PartitionPage::PartitionPage( PartitionCoreModule* core, const Config& config, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_ui( new Ui_PartitionPage )
|
||||
, m_core( core )
|
||||
@@ -119,9 +119,8 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, const Config & config,
|
||||
m_ui->label_3->hide();
|
||||
}
|
||||
|
||||
CALAMARES_RETRANSLATE(
|
||||
m_ui->retranslateUi( this );
|
||||
m_core->bootLoaderModel()->update(); // Need to re-translate entries in the combo-box
|
||||
CALAMARES_RETRANSLATE( m_ui->retranslateUi( this );
|
||||
m_core->bootLoaderModel()->update(); // Need to re-translate entries in the combo-box
|
||||
);
|
||||
}
|
||||
|
||||
@@ -281,28 +280,30 @@ PartitionPage::checkCanCreate( Device* device )
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PartitionPage::onNewVolumeGroupClicked()
|
||||
static inline PartitionVector
|
||||
availablePVs( PartitionCoreModule* core )
|
||||
{
|
||||
QString vgName;
|
||||
QVector< const Partition* > selectedPVs;
|
||||
qint64 peSize = 4;
|
||||
PartitionVector availablePVs;
|
||||
|
||||
QVector< const Partition* > availablePVs;
|
||||
|
||||
for ( const Partition* p : m_core->lvmPVs() )
|
||||
for ( const Partition* p : core->lvmPVs() )
|
||||
{
|
||||
if ( !m_core->isInVG( p ) )
|
||||
if ( !core->isInVG( p ) )
|
||||
{
|
||||
availablePVs << p;
|
||||
}
|
||||
}
|
||||
return availablePVs;
|
||||
}
|
||||
|
||||
QPointer< CreateVolumeGroupDialog > dlg
|
||||
= new CreateVolumeGroupDialog( vgName, selectedPVs, availablePVs, peSize, this );
|
||||
|
||||
void
|
||||
PartitionPage::onNewVolumeGroupClicked()
|
||||
{
|
||||
QPointer< CreateVolumeGroupDialog > dlg = new CreateVolumeGroupDialog( availablePVs( m_core ), 4, this );
|
||||
|
||||
if ( dlg->exec() == QDialog::Accepted )
|
||||
{
|
||||
const PartitionVector selectedPVs = dlg->selectedPVs();
|
||||
QModelIndex partitionIndex = m_ui->partitionTreeView->currentIndex();
|
||||
|
||||
if ( partitionIndex.isValid() )
|
||||
@@ -326,7 +327,7 @@ PartitionPage::onNewVolumeGroupClicked()
|
||||
QVariant previousIndexDeviceData = m_core->deviceModel()->data( deviceIndex, Qt::ToolTipRole );
|
||||
|
||||
// Creating new VG
|
||||
m_core->createVolumeGroup( vgName, selectedPVs, peSize );
|
||||
m_core->createVolumeGroup( dlg->volumeGroupName(), selectedPVs, dlg->physicalExtentSize() );
|
||||
|
||||
// As createVolumeGroup method call resets deviceModel,
|
||||
// is needed to set the current index in deviceComboBox as the previous one
|
||||
@@ -347,9 +348,10 @@ PartitionPage::onResizeVolumeGroupClicked()
|
||||
|
||||
Q_ASSERT( device && device->type() == Device::Type::LVM_Device );
|
||||
|
||||
QVector< const Partition* > availablePVs;
|
||||
QVector< const Partition* > selectedPVs;
|
||||
<<<<<<< HEAD
|
||||
ResizeVolumeGroupDialog::PartitionVector selectedPVs;
|
||||
|
||||
<<<<<<< HEAD
|
||||
for ( const Partition* p : m_core->lvmPVs() )
|
||||
{
|
||||
if ( !m_core->isInVG( p ) )
|
||||
@@ -359,10 +361,17 @@ PartitionPage::onResizeVolumeGroupClicked()
|
||||
}
|
||||
|
||||
QPointer< ResizeVolumeGroupDialog > dlg = new ResizeVolumeGroupDialog( device, availablePVs, selectedPVs, this );
|
||||
=======
|
||||
QPointer< ResizeVolumeGroupDialog > dlg
|
||||
= new ResizeVolumeGroupDialog( device, availablePVs( m_core ), selectedPVs, this );
|
||||
>>>>>>> 2c16d812c ([partition] Factor out determining which PVs exist)
|
||||
=======
|
||||
QPointer< ResizeVolumeGroupDialog > dlg = new ResizeVolumeGroupDialog( device, availablePVs( m_core ), this );
|
||||
>>>>>>> f1185d38d ([partition] Drop unneeded parameters and stored references)
|
||||
|
||||
if ( dlg->exec() == QDialog::Accepted )
|
||||
{
|
||||
m_core->resizeVolumeGroup( device, selectedPVs );
|
||||
m_core->resizeVolumeGroup( device, dlg->selectedPVs() );
|
||||
}
|
||||
|
||||
delete dlg;
|
||||
@@ -514,8 +523,8 @@ PartitionPage::updatePartitionToCreate( Device* device, Partition* partition )
|
||||
QStringList mountPoints = getCurrentUsedMountpoints();
|
||||
mountPoints.removeOne( PartitionInfo::mountPoint( partition ) );
|
||||
|
||||
QPointer< CreatePartitionDialog > dlg
|
||||
= new CreatePartitionDialog( m_core, device, CreatePartitionDialog::FreshPartition { partition }, mountPoints, this );
|
||||
QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog(
|
||||
m_core, device, CreatePartitionDialog::FreshPartition { partition }, mountPoints, this );
|
||||
if ( dlg->exec() == QDialog::Accepted )
|
||||
{
|
||||
Partition* newPartition = dlg->getNewlyCreatedPartition();
|
||||
|
||||
@@ -22,38 +22,28 @@
|
||||
|
||||
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog( LvmDevice* device,
|
||||
const PartitionVector& availablePVs,
|
||||
PartitionVector& selectedPVs,
|
||||
QWidget* parent )
|
||||
: VolumeGroupBaseDialog( device->name(), device->physicalVolumes(), parent )
|
||||
, m_selectedPVs( selectedPVs )
|
||||
: VolumeGroupBaseDialog( parent, device->name(), device->physicalVolumes() )
|
||||
{
|
||||
setWindowTitle( tr( "Resize Volume Group", "@title" ) );
|
||||
|
||||
for ( int i = 0; i < pvList()->count(); i++ )
|
||||
for ( int i = 0; i < pvListWidget()->count(); i++ )
|
||||
{
|
||||
pvList()->item( i )->setCheckState( Qt::Checked );
|
||||
pvListWidget()->item( i )->setCheckState( Qt::Checked );
|
||||
}
|
||||
|
||||
for ( const Partition* p : availablePVs )
|
||||
{
|
||||
pvList()->addItem( new ListPhysicalVolumeWidgetItem( p, false ) );
|
||||
pvListWidget()->addItem( new ListPhysicalVolumeWidgetItem( p, false ) );
|
||||
}
|
||||
|
||||
peSize()->setValue(
|
||||
peSizeWidget()->setValue(
|
||||
static_cast< int >( device->peSize() / Capacity::unitFactor( Capacity::Unit::Byte, Capacity::Unit::MiB ) ) );
|
||||
|
||||
vgName()->setEnabled( false );
|
||||
peSize()->setEnabled( false );
|
||||
vgType()->setEnabled( false );
|
||||
vgNameWidget()->setEnabled( false );
|
||||
peSizeWidget()->setEnabled( false );
|
||||
vgTypeWidget()->setEnabled( false );
|
||||
|
||||
setUsedSizeValue( device->allocatedPE() * device->peSize() );
|
||||
setLVQuantity( device->partitionTable()->children().count() );
|
||||
}
|
||||
|
||||
void
|
||||
ResizeVolumeGroupDialog::accept()
|
||||
{
|
||||
m_selectedPVs << checkedItems();
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
@@ -19,17 +19,7 @@ class ResizeVolumeGroupDialog : public VolumeGroupBaseDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using PartitionVector = QVector< const Partition* >;
|
||||
|
||||
ResizeVolumeGroupDialog( LvmDevice* device,
|
||||
const PartitionVector& availablePVs,
|
||||
PartitionVector& selectedPVs,
|
||||
QWidget* parent );
|
||||
|
||||
void accept() override;
|
||||
|
||||
private:
|
||||
PartitionVector& m_selectedPVs;
|
||||
ResizeVolumeGroupDialog( LvmDevice* device, const PartitionVector& availablePVs, QWidget* parent );
|
||||
};
|
||||
|
||||
#endif // RESIZEVOLUMEGROUPDIALOG_H
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "VolumeGroupBaseDialog.h"
|
||||
#include "ui_VolumeGroupBaseDialog.h"
|
||||
|
||||
#include "core/PartitionCoreModule.h"
|
||||
#include "core/SizeUtils.h"
|
||||
#include "gui/ListPhysicalVolumeWidgetItem.h"
|
||||
|
||||
@@ -20,10 +21,11 @@
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
|
||||
VolumeGroupBaseDialog::VolumeGroupBaseDialog( QString& vgName, QVector< const Partition* > pvList, QWidget* parent )
|
||||
// Keeping the sources consistent
|
||||
VolumeGroupBaseDialog::VolumeGroupBaseDialog( QWidget* parent, const QString& vgName, PartitionVector pvList )
|
||||
: QDialog( parent )
|
||||
, ui( new Ui::VolumeGroupBaseDialog )
|
||||
, m_vgNameValue( vgName )
|
||||
, m_volumeGroupName( vgName )
|
||||
, m_totalSizeValue( 0 )
|
||||
, m_usedSizeValue( 0 )
|
||||
{
|
||||
@@ -34,13 +36,12 @@ VolumeGroupBaseDialog::VolumeGroupBaseDialog( QString& vgName, QVector< const Pa
|
||||
ui->pvList->addItem( new ListPhysicalVolumeWidgetItem( p, false ) );
|
||||
}
|
||||
|
||||
ui->vgType->addItems( QStringList() << "LVM"
|
||||
<< "RAID" );
|
||||
ui->vgType->addItems( { "LVM", "RAID" } );
|
||||
ui->vgType->setCurrentIndex( 0 );
|
||||
|
||||
QRegularExpression re( R"(^(?!_|\.)[\w\-.+]+)" );
|
||||
ui->vgName->setValidator( new QRegularExpressionValidator( re, this ) );
|
||||
ui->vgName->setText( m_vgNameValue );
|
||||
ui->vgName->setText( vgName );
|
||||
|
||||
updateOkButton();
|
||||
updateTotalSize();
|
||||
@@ -63,7 +64,14 @@ VolumeGroupBaseDialog::VolumeGroupBaseDialog( QString& vgName, QVector< const Pa
|
||||
updateOkButton();
|
||||
} );
|
||||
|
||||
connect( ui->vgName, &QLineEdit::textChanged, this, [ & ]( const QString& ) { updateOkButton(); } );
|
||||
connect( ui->vgName,
|
||||
&QLineEdit::textChanged,
|
||||
this,
|
||||
[ & ]( const QString& s )
|
||||
{
|
||||
m_volumeGroupName = s;
|
||||
updateOkButton();
|
||||
} );
|
||||
}
|
||||
|
||||
VolumeGroupBaseDialog::~VolumeGroupBaseDialog()
|
||||
@@ -71,10 +79,10 @@ VolumeGroupBaseDialog::~VolumeGroupBaseDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QVector< const Partition* >
|
||||
VolumeGroupBaseDialog::checkedItems() const
|
||||
PartitionVector
|
||||
VolumeGroupBaseDialog::selectedPVs() const
|
||||
{
|
||||
QVector< const Partition* > items;
|
||||
PartitionVector items;
|
||||
|
||||
for ( int i = 0; i < ui->pvList->count(); i++ )
|
||||
{
|
||||
@@ -98,8 +106,8 @@ VolumeGroupBaseDialog::isSizeValid() const
|
||||
void
|
||||
VolumeGroupBaseDialog::updateOkButton()
|
||||
{
|
||||
okButton()->setEnabled( isSizeValid() && !checkedItems().empty() && !ui->vgName->text().isEmpty()
|
||||
&& ui->peSize->value() > 0 );
|
||||
okButtonWidget()->setEnabled( isSizeValid() && !selectedPVs().empty() && !ui->vgName->text().isEmpty()
|
||||
&& ui->peSize->value() > 0 );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -119,13 +127,14 @@ VolumeGroupBaseDialog::setLVQuantity( qint32 lvQuantity )
|
||||
void
|
||||
VolumeGroupBaseDialog::updateTotalSize()
|
||||
{
|
||||
m_physicalExtentSize = peSizeWidget()->value();
|
||||
m_totalSizeValue = 0;
|
||||
|
||||
for ( const Partition* p : checkedItems() )
|
||||
for ( const Partition* p : selectedPVs() )
|
||||
{
|
||||
m_totalSizeValue += p->capacity()
|
||||
- p->capacity()
|
||||
% ( ui->peSize->value() * Capacity::unitFactor( Capacity::Unit::Byte, Capacity::Unit::MiB ) );
|
||||
% ( m_physicalExtentSize * Capacity::unitFactor( Capacity::Unit::Byte, Capacity::Unit::MiB ) );
|
||||
}
|
||||
|
||||
ui->totalSize->setText( formatByteSize( m_totalSizeValue ) );
|
||||
@@ -136,9 +145,10 @@ VolumeGroupBaseDialog::updateTotalSize()
|
||||
void
|
||||
VolumeGroupBaseDialog::updateTotalSectors()
|
||||
{
|
||||
qint64 totalSectors = 0;
|
||||
m_physicalExtentSize = peSizeWidget()->value();
|
||||
|
||||
qint64 extentSize = ui->peSize->value() * Capacity::unitFactor( Capacity::Unit::Byte, Capacity::Unit::MiB );
|
||||
qint64 totalSectors = 0;
|
||||
qint64 extentSize = m_physicalExtentSize * Capacity::unitFactor( Capacity::Unit::Byte, Capacity::Unit::MiB );
|
||||
|
||||
if ( extentSize > 0 )
|
||||
{
|
||||
@@ -148,38 +158,32 @@ VolumeGroupBaseDialog::updateTotalSectors()
|
||||
ui->totalSectors->setText( QString::number( totalSectors ) );
|
||||
}
|
||||
|
||||
QString&
|
||||
VolumeGroupBaseDialog::vgNameValue() const
|
||||
{
|
||||
return m_vgNameValue;
|
||||
}
|
||||
|
||||
QLineEdit*
|
||||
VolumeGroupBaseDialog::vgName() const
|
||||
VolumeGroupBaseDialog::vgNameWidget() const
|
||||
{
|
||||
return ui->vgName;
|
||||
}
|
||||
|
||||
QComboBox*
|
||||
VolumeGroupBaseDialog::vgType() const
|
||||
VolumeGroupBaseDialog::vgTypeWidget() const
|
||||
{
|
||||
return ui->vgType;
|
||||
}
|
||||
|
||||
QSpinBox*
|
||||
VolumeGroupBaseDialog::peSize() const
|
||||
VolumeGroupBaseDialog::peSizeWidget() const
|
||||
{
|
||||
return ui->peSize;
|
||||
}
|
||||
|
||||
QListWidget*
|
||||
VolumeGroupBaseDialog::pvList() const
|
||||
VolumeGroupBaseDialog::pvListWidget() const
|
||||
{
|
||||
return ui->pvList;
|
||||
}
|
||||
|
||||
QPushButton*
|
||||
VolumeGroupBaseDialog::okButton() const
|
||||
VolumeGroupBaseDialog::okButtonWidget() const
|
||||
{
|
||||
return ui->buttonBox->button( QDialogButtonBox::StandardButton::Ok );
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef VOLUMEGROUPBASEDIALOG_H
|
||||
#define VOLUMEGROUPBASEDIALOG_H
|
||||
|
||||
#include <kpmcore/core/partition.h>
|
||||
#include "core/KPMHelpers.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
@@ -29,43 +29,46 @@ class VolumeGroupBaseDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VolumeGroupBaseDialog( QString& vgName, QVector< const Partition* > pvList, QWidget* parent = nullptr );
|
||||
explicit VolumeGroupBaseDialog( QWidget* parent, const QString& vgName, PartitionVector pvList );
|
||||
~VolumeGroupBaseDialog() override;
|
||||
|
||||
qint32 physicalExtentSize() const { return m_physicalExtentSize; }
|
||||
QString volumeGroupName() const { return m_volumeGroupName; }
|
||||
/** @brief Which PVs (partitions) are selected for this VG
|
||||
*
|
||||
* The vector contains non-owned pointers.
|
||||
*/
|
||||
PartitionVector selectedPVs() const;
|
||||
|
||||
protected:
|
||||
virtual void updateOkButton();
|
||||
|
||||
void setUsedSizeValue( qint64 usedSize );
|
||||
|
||||
void setLVQuantity( qint32 lvQuantity );
|
||||
|
||||
void updateTotalSize();
|
||||
|
||||
void updateTotalSectors();
|
||||
|
||||
QVector< const Partition* > checkedItems() const;
|
||||
|
||||
bool isSizeValid() const;
|
||||
|
||||
QString& vgNameValue() const;
|
||||
void updateTotalSize();
|
||||
void updateTotalSectors();
|
||||
|
||||
QLineEdit* vgName() const;
|
||||
|
||||
QComboBox* vgType() const;
|
||||
|
||||
QSpinBox* peSize() const;
|
||||
|
||||
QListWidget* pvList() const;
|
||||
|
||||
QPushButton* okButton() const;
|
||||
/** @section UI-widget accessors
|
||||
*
|
||||
* These methods get UI internal widgets, so that subclasses
|
||||
* can manipulate the values in those widgets.
|
||||
*/
|
||||
QLineEdit* vgNameWidget() const;
|
||||
QComboBox* vgTypeWidget() const;
|
||||
QSpinBox* peSizeWidget() const;
|
||||
QListWidget* pvListWidget() const;
|
||||
QPushButton* okButtonWidget() const;
|
||||
|
||||
private:
|
||||
Ui::VolumeGroupBaseDialog* ui;
|
||||
|
||||
QString& m_vgNameValue;
|
||||
|
||||
QString m_volumeGroupName;
|
||||
qint64 m_totalSizeValue;
|
||||
qint64 m_usedSizeValue;
|
||||
qint32 m_physicalExtentSize;
|
||||
};
|
||||
|
||||
#endif // VOLUMEGROUPBASEDIALOG_H
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
#include <kpmcore/util/report.h>
|
||||
|
||||
CreateVolumeGroupJob::CreateVolumeGroupJob( Device*,
|
||||
QString& vgName,
|
||||
QVector< const Partition* > pvList,
|
||||
const QString& vgName,
|
||||
const PartitionVector& pvList,
|
||||
const qint32 peSize )
|
||||
: m_vgName( vgName )
|
||||
, m_pvList( pvList )
|
||||
, m_peSize( peSize )
|
||||
, m_physicalExtentSize( peSize )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ CreateVolumeGroupJob::prettyStatusMessage() const
|
||||
Calamares::JobResult
|
||||
CreateVolumeGroupJob::exec()
|
||||
{
|
||||
return KPMHelpers::execute( CreateVolumeGroupOperation( m_vgName, m_pvList, m_peSize ),
|
||||
return KPMHelpers::execute( CreateVolumeGroupOperation( m_vgName, m_pvList, m_physicalExtentSize ),
|
||||
tr( "The installer failed to create a volume group named '%1'." ).arg( m_vgName ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -10,19 +10,23 @@
|
||||
#ifndef CREATEVOLUMEGROUPJOB_H
|
||||
#define CREATEVOLUMEGROUPJOB_H
|
||||
|
||||
#include "core/KPMHelpers.h"
|
||||
|
||||
#include "Job.h"
|
||||
#include "partition/KPMManager.h"
|
||||
|
||||
#include <QVector>
|
||||
|
||||
class Device;
|
||||
class Partition;
|
||||
|
||||
class CreateVolumeGroupJob : public Calamares::Job
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CreateVolumeGroupJob( Device*, QString& vgName, QVector< const Partition* > pvList, const qint32 peSize );
|
||||
/** @brief Make a job that will create a volume group
|
||||
*
|
||||
* The @p physicalExtentSize is given in MiB; typically this is 4 (MiB).
|
||||
*/
|
||||
CreateVolumeGroupJob( Device*,
|
||||
const QString& vgName,
|
||||
const PartitionVector& pvList,
|
||||
const qint32 physicalExtentSize );
|
||||
|
||||
QString prettyName() const override;
|
||||
QString prettyDescription() const override;
|
||||
@@ -35,8 +39,8 @@ public:
|
||||
private:
|
||||
Calamares::Partition::KPMManager m_kpmcore;
|
||||
QString m_vgName;
|
||||
QVector< const Partition* > m_pvList;
|
||||
qint32 m_peSize;
|
||||
PartitionVector m_pvList;
|
||||
qint32 m_physicalExtentSize;
|
||||
};
|
||||
|
||||
#endif // CREATEVOLUMEGROUPJOB_H
|
||||
|
||||
@@ -9,14 +9,12 @@
|
||||
|
||||
#include "ResizeVolumeGroupJob.h"
|
||||
|
||||
#include "core/KPMHelpers.h"
|
||||
|
||||
#include <kpmcore/core/lvmdevice.h>
|
||||
#include <kpmcore/core/partition.h>
|
||||
#include <kpmcore/ops/resizevolumegroupoperation.h>
|
||||
#include <kpmcore/util/report.h>
|
||||
|
||||
ResizeVolumeGroupJob::ResizeVolumeGroupJob( Device*, LvmDevice* device, QVector< const Partition* >& partitionList )
|
||||
ResizeVolumeGroupJob::ResizeVolumeGroupJob( Device*, LvmDevice* device, const PartitionVector& partitionList )
|
||||
: m_device( device )
|
||||
, m_partitionList( partitionList )
|
||||
{
|
||||
|
||||
@@ -10,20 +10,19 @@
|
||||
#ifndef RESIZEVOLUMEGROUPJOB_H
|
||||
#define RESIZEVOLUMEGROUPJOB_H
|
||||
|
||||
#include "core/KPMHelpers.h"
|
||||
|
||||
#include "Job.h"
|
||||
#include "partition/KPMManager.h"
|
||||
|
||||
#include <QVector>
|
||||
|
||||
class Device;
|
||||
class LvmDevice;
|
||||
class Partition;
|
||||
|
||||
class ResizeVolumeGroupJob : public Calamares::Job
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ResizeVolumeGroupJob( Device*, LvmDevice* device, QVector< const Partition* >& partitionList );
|
||||
ResizeVolumeGroupJob( Device*, LvmDevice* device, const PartitionVector& partitionList );
|
||||
|
||||
QString prettyName() const override;
|
||||
QString prettyDescription() const override;
|
||||
@@ -37,7 +36,7 @@ private:
|
||||
private:
|
||||
Calamares::Partition::KPMManager m_kpmcore;
|
||||
LvmDevice* m_device;
|
||||
QVector< const Partition* > m_partitionList;
|
||||
PartitionVector m_partitionList;
|
||||
};
|
||||
|
||||
#endif // RESIZEVOLUMEGROUPJOB_H
|
||||
|
||||
Reference in New Issue
Block a user