Clean up a bit.

main
Teo Mrnjavac 9 years ago
parent 6db6dc0e08
commit f31a45e53a

@ -442,28 +442,7 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice )
watcher->deleteLater(); watcher->deleteLater();
} ); } );
auto doReplace = [ this, current ] QFuture< void > future = QtConcurrent::run( this, &ChoicePage::doReplaceSelectedPartition, current );
{
cDebug() << "begin doReplace";
QMutexLocker( &( ChoicePage::m_coreMutex ) );
if ( m_core->isDirty() )
{
m_core->revertDevice( selectedDevice() );
}
// We can't use the PartitionPtrRole because we need to make changes to the
// main DeviceModel, not the immutable copy.
QString partPath = current.data( PartitionModel::PartitionPathRole ).toString();
Partition* partition = KPMHelpers::findPartitionByPath( { selectedDevice() },
partPath );
if ( partition )
PartitionActions::doReplacePartition( m_core,
selectedDevice(),
partition );
cDebug() << "end doReplace";
};
QFuture< void > future = QtConcurrent::run( doReplace );
watcher->setFuture( future ); watcher->setFuture( future );
} ); } );
break; break;
@ -475,6 +454,29 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice )
} }
void
ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
{
cDebug() << "begin doReplace";
QMutexLocker locker( &m_coreMutex );
if ( m_core->isDirty() )
{
m_core->revertDevice( selectedDevice() );
}
// We can't use the PartitionPtrRole because we need to make changes to the
// main DeviceModel, not the immutable copy.
QString partPath = current.data( PartitionModel::PartitionPathRole ).toString();
Partition* partition = KPMHelpers::findPartitionByPath( { selectedDevice() },
partPath );
if ( partition )
PartitionActions::doReplacePartition( m_core,
selectedDevice(),
partition );
cDebug() << "end doReplace";
}
/** /**
* @brief ChoicePage::updateDeviceStatePreview clears and rebuilds the contents of the * @brief ChoicePage::updateDeviceStatePreview clears and rebuilds the contents of the
* preview widget for the current on-disk state. This also triggers a rescan in the * preview widget for the current on-disk state. This also triggers a rescan in the

@ -76,6 +76,7 @@ private:
ExpandableRadioButton* createEraseButton(); ExpandableRadioButton* createEraseButton();
Device* selectedDevice(); Device* selectedDevice();
void applyDeviceChoice(); void applyDeviceChoice();
void doReplaceSelectedPartition( const QModelIndex& current );
void updateDeviceStatePreview(); void updateDeviceStatePreview();
void applyActionChoice( ChoicePage::Choice choice ); void applyActionChoice( ChoicePage::Choice choice );
void updateActionChoicePreview( ChoicePage::Choice choice ); void updateActionChoicePreview( ChoicePage::Choice choice );

Loading…
Cancel
Save