Skip to content
Snippets Groups Projects
Commit 2e173c18 authored by Teo Mrnjavac's avatar Teo Mrnjavac
Browse files

Do not align partition boundaries unless explicitly requested.

parent 9d995f36
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,8 @@ PartitionSizeController::setPartResizerWidget( PartResizerWidget* widget, bool f
if ( m_partResizerWidget )
disconnect( m_partResizerWidget, 0, this, 0 );
m_dirty = false;
// Update partition filesystem. This must be done *before* the call to
// PartResizerWidget::init() otherwise it will be ignored by the widget.
// This is why this method accept a `format` boolean.
......@@ -84,7 +86,17 @@ PartitionSizeController::setPartResizerWidget( PartResizerWidget* widget, bool f
// If we are not formatting, update the widget to make sure the space
// between the first and last sectors is big enough to fit the existing
// content.
updatePartResizerWidget();
m_updating = true;
qint64 firstSector = m_partition->firstSector();
qint64 lastSector = m_partition->lastSector();
// This first time we call doAAUPRW with real first/last sector,
// all further calls will come from updatePartResizerWidget, and
// will therefore use values calculated from the SpinBox.
doAlignAndUpdatePartResizerWidget( firstSector, lastSector );
m_updating = false;
}
}
......@@ -122,18 +134,35 @@ PartitionSizeController::updatePartResizerWidget()
qint64 firstSector = m_partition->firstSector();
qint64 lastSector = firstSector + sectorSize - 1;
doAlignAndUpdatePartResizerWidget( firstSector, lastSector );
m_updating = false;
}
void
PartitionSizeController::doAlignAndUpdatePartResizerWidget( qint64 firstSector,
qint64 lastSector )
{
if ( lastSector > m_partResizerWidget->maximumLastSector() )
{
qint64 delta = lastSector - m_partResizerWidget->maximumLastSector();
firstSector -= delta;
lastSector -= delta;
}
m_partResizerWidget->updateLastSector( lastSector );
m_partResizerWidget->updateFirstSector( firstSector );
if ( lastSector != m_partition->lastSector() )
{
m_partResizerWidget->updateLastSector( lastSector );
m_dirty = true;
}
if ( firstSector != m_partition->firstSector() )
{
m_partResizerWidget->updateFirstSector( firstSector );
m_dirty = true;
}
// Update spinbox value in case it was an impossible value
doUpdateSpinBox();
m_updating = false;
}
void
......@@ -166,3 +195,9 @@ PartitionSizeController::lastSector() const
{
return m_partition->lastSector();
}
bool
PartitionSizeController::isDirty() const
{
return m_dirty;
}
......@@ -53,6 +53,8 @@ public:
qint64 firstSector() const;
qint64 lastSector() const;
bool isDirty() const;
private:
QPointer< PartResizerWidget > m_partResizerWidget;
QPointer< QSpinBox > m_spinBox;
......@@ -65,6 +67,9 @@ private:
void connectWidgets();
void doUpdateSpinBox();
void doAlignAndUpdatePartResizerWidget( qint64 fistSector, qint64 lastSector );
bool m_dirty = false;
private Q_SLOTS:
void updatePartResizerWidget();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment