parent
675b07799b
commit
c3a91f1c8d
@ -60,6 +60,20 @@ PartitionCoreModule::DeviceInfo::forgetChanges()
|
||||
PartitionInfo::reset( *it );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PartitionCoreModule::DeviceInfo::isDirty() const
|
||||
{
|
||||
if ( !jobs.isEmpty() )
|
||||
return true;
|
||||
|
||||
for ( auto it = PartitionIterator::begin( device.data() ); it != PartitionIterator::end( device.data() ); ++it )
|
||||
if ( PartitionInfo::isDirty( *it ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//- PartitionCoreModule ------------------------------------
|
||||
PartitionCoreModule::PartitionCoreModule( QObject* parent )
|
||||
: QObject( parent )
|
||||
@ -70,6 +84,12 @@ PartitionCoreModule::PartitionCoreModule( QObject* parent )
|
||||
if ( !CalaPM::init() )
|
||||
qFatal( "Failed to init CalaPM" );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
void
|
||||
PartitionCoreModule::init()
|
||||
{
|
||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
||||
auto devices = backend->scanDevices();
|
||||
for ( auto device : devices )
|
||||
@ -248,6 +268,7 @@ PartitionCoreModule::refresh( Device* device )
|
||||
Q_ASSERT( model );
|
||||
model->reload();
|
||||
updateHasRootMountPoint();
|
||||
updateIsDirty();
|
||||
m_bootLoaderModel->update();
|
||||
}
|
||||
|
||||
@ -260,6 +281,21 @@ void PartitionCoreModule::updateHasRootMountPoint()
|
||||
hasRootMountPointChanged( m_hasRootMountPoint );
|
||||
}
|
||||
|
||||
void
|
||||
PartitionCoreModule::updateIsDirty()
|
||||
{
|
||||
bool oldValue = m_isDirty;
|
||||
m_isDirty = false;
|
||||
for ( auto info : m_deviceInfos )
|
||||
if ( info->isDirty() )
|
||||
{
|
||||
m_isDirty = true;
|
||||
break;
|
||||
}
|
||||
if ( oldValue != m_isDirty )
|
||||
isDirtyChanged( m_isDirty );
|
||||
}
|
||||
|
||||
PartitionCoreModule::DeviceInfo*
|
||||
PartitionCoreModule::infoForDevice( Device* device ) const
|
||||
{
|
||||
@ -289,3 +325,12 @@ PartitionCoreModule::setBootLoaderInstallPath( const QString& path )
|
||||
{
|
||||
m_bootLoaderInstallPath = path;
|
||||
}
|
||||
|
||||
void
|
||||
PartitionCoreModule::revert()
|
||||
{
|
||||
qDeleteAll( m_deviceInfos );
|
||||
m_deviceInfos.clear();
|
||||
init();
|
||||
updateIsDirty();
|
||||
}
|
||||
|
@ -73,8 +73,11 @@ public:
|
||||
|
||||
void refresh( Device* device );
|
||||
|
||||
void revert();
|
||||
|
||||
Q_SIGNALS:
|
||||
void hasRootMountPointChanged( bool value );
|
||||
void isDirtyChanged( bool value );
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -89,15 +92,19 @@ private:
|
||||
QList< Calamares::job_ptr > jobs;
|
||||
|
||||
void forgetChanges();
|
||||
bool isDirty() const;
|
||||
};
|
||||
QList< DeviceInfo* > m_deviceInfos;
|
||||
|
||||
DeviceModel* m_deviceModel;
|
||||
BootLoaderModel* m_bootLoaderModel;
|
||||
bool m_hasRootMountPoint = false;
|
||||
bool m_isDirty = false;
|
||||
QString m_bootLoaderInstallPath;
|
||||
|
||||
void init();
|
||||
void updateHasRootMountPoint();
|
||||
void updateIsDirty();
|
||||
|
||||
void dumpQueue() const;
|
||||
|
||||
|
@ -60,4 +60,11 @@ reset( Partition* partition )
|
||||
partition->setProperty( FORMAT_PROPERTY, QVariant() );
|
||||
}
|
||||
|
||||
bool
|
||||
isDirty( Partition* partition )
|
||||
{
|
||||
return !mountPoint( partition ).isEmpty()
|
||||
|| format( partition );
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -38,6 +38,8 @@ void setFormat( Partition* partition, bool value );
|
||||
|
||||
void reset( Partition* partition );
|
||||
|
||||
bool isDirty( Partition* partition );
|
||||
|
||||
};
|
||||
|
||||
#endif /* PARTITIONINFO_H */
|
||||
|
@ -65,7 +65,9 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
|
||||
updateBootLoaderInstallPath();
|
||||
} );
|
||||
|
||||
connect( m_core, &PartitionCoreModule::isDirtyChanged, m_ui->revertButton, &QWidget::setEnabled );
|
||||
|
||||
connect( m_ui->revertButton, &QAbstractButton::clicked, this, &PartitionPage::onRevertClicked );
|
||||
connect( m_ui->newPartitionTableButton, &QAbstractButton::clicked, this, &PartitionPage::onNewPartitionTableClicked );
|
||||
connect( m_ui->createButton, &QAbstractButton::clicked, this, &PartitionPage::onCreateClicked );
|
||||
connect( m_ui->editButton, &QAbstractButton::clicked, this, &PartitionPage::onEditClicked );
|
||||
@ -174,6 +176,15 @@ PartitionPage::onDeleteClicked()
|
||||
m_core->deletePartition( model->device(), partition );
|
||||
}
|
||||
|
||||
void
|
||||
PartitionPage::onRevertClicked()
|
||||
{
|
||||
int oldIndex = m_ui->deviceComboBox->currentIndex();
|
||||
m_core->revert();
|
||||
m_ui->deviceComboBox->setCurrentIndex( oldIndex );
|
||||
updateFromCurrentDevice();
|
||||
}
|
||||
|
||||
void
|
||||
PartitionPage::updatePartitionToCreate( Device* device, Partition* partition )
|
||||
{
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
QScopedPointer< Ui_PartitionPage > m_ui;
|
||||
PartitionCoreModule* m_core;
|
||||
void updateButtons();
|
||||
void onRevertClicked();
|
||||
void onNewPartitionTableClicked();
|
||||
void onCreateClicked();
|
||||
void onEditClicked();
|
||||
|
@ -42,6 +42,16 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="revertButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Revert All Changes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
Reference in New Issue
Block a user