Merge branch 'issue-1061'

FIXES #1061
main
Adriaan de Groot 6 years ago
commit 3ddb49afb7

@ -2,6 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -46,9 +47,15 @@ BootLoaderModel::~BootLoaderModel()
void
BootLoaderModel::init( const QList< Device* >& devices )
{
beginResetModel();
blockSignals( true );
m_devices = devices;
clear();
createMbrItems();
blockSignals( false );
endResetModel();
}
void
@ -69,6 +76,16 @@ BootLoaderModel::update()
{
beginResetModel();
blockSignals( true );
updateInternal();
blockSignals( false );
endResetModel();
}
void
BootLoaderModel::updateInternal()
{
QMutexLocker lock(&m_lock);
clear();
createMbrItems();
@ -113,14 +130,13 @@ BootLoaderModel::update()
createBootLoaderItem( tr( "Do not install a boot loader" ), QString(), false )
);
}
blockSignals( false );
endResetModel();
}
QVariant
BootLoaderModel::data( const QModelIndex& index, int role ) const
{
QMutexLocker lock(&m_lock);
if ( role == Qt::DisplayRole )
{
QString displayRole = QStandardItemModel::data( index, Qt::DisplayRole ).toString();

@ -2,6 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,8 +20,9 @@
#ifndef BOOTLOADERMODEL_H
#define BOOTLOADERMODEL_H
#include <QStandardItemModel>
#include <QList>
#include <QMutex>
#include <QStandardItemModel>
class Device;
@ -51,10 +53,14 @@ public:
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
using DeviceList = QList< Device* >;
private:
QList< Device* > m_devices;
DeviceList m_devices;
mutable QMutex m_lock;
void createMbrItems();
void updateInternal();
};
#endif /* BOOTLOADERMODEL_H */

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018-2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

@ -2,6 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -35,6 +36,15 @@
// STL
#include <algorithm>
static void
sortDevices( DeviceModel::DeviceList& l )
{
std::sort( l.begin(), l.end(), []( const Device* dev1, const Device* dev2 )
{
return dev1->deviceNode() < dev2->deviceNode();
} );
}
DeviceModel::DeviceModel( QObject* parent )
: QAbstractListModel( parent )
{
@ -45,14 +55,11 @@ DeviceModel::~DeviceModel()
}
void
DeviceModel::init( const QList< Device* >& devices )
DeviceModel::init( const DeviceList& devices )
{
beginResetModel();
m_devices = devices;
std::sort( m_devices.begin(), m_devices.end(), []( const Device* dev1, const Device* dev2 )
{
return dev1->deviceNode() < dev2->deviceNode();
} );
sortDevices( m_devices );
endResetModel();
}
@ -138,13 +145,8 @@ void
DeviceModel::addDevice( Device *device )
{
beginResetModel();
m_devices << device;
std::sort( m_devices.begin(), m_devices.end(), []( const Device* dev1, const Device* dev2 )
{
return dev1->deviceNode() < dev2->deviceNode();
} );
sortDevices( m_devices );
endResetModel();
}
@ -152,12 +154,7 @@ void
DeviceModel::removeDevice( Device *device )
{
beginResetModel();
m_devices.removeAll( device );
std::sort( m_devices.begin(), m_devices.end(), []( const Device* dev1, const Device* dev2 )
{
return dev1->deviceNode() < dev2->deviceNode();
} );
sortDevices( m_devices );
endResetModel();
}

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
* Copyright 2017, 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -36,11 +36,13 @@ public:
DeviceModel( QObject* parent = nullptr );
~DeviceModel() override;
using DeviceList = QList< Device* >;
/**
* Init the model with the list of devices. Does *not* take ownership of the
* devices.
*/
void init( const QList< Device* >& devices );
void init( const DeviceList& devices );
int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
@ -54,7 +56,7 @@ public:
void removeDevice( Device* device );
private:
QList< Device* > m_devices;
DeviceList m_devices;
};
#endif /* DEVICEMODEL_H */

@ -2,7 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018-2019 Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

@ -2,6 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018-2019 Adriaan de Groot <groot@kde.org>
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
*
* Calamares is free software: you can redistribute it and/or modify

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018-2019 Adriaan de Groot <groot@kde.org>
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
*
* Calamares is free software: you can redistribute it and/or modify

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* Copyright 2017-2019, Adriaan de Groot <groot@kde.org>
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
*
* Calamares is free software: you can redistribute it and/or modify

@ -2,7 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* Copyright 2017-2019, Adriaan de Groot <groot@kde.org>
* Copyright 2018, Caio Carvalho <caiojcarvalho@gmail.com>
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
*

@ -2,6 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018-2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -40,11 +40,16 @@
PartitionModel::ResetHelper::ResetHelper( PartitionModel* model )
: m_model( model )
{
m_model->m_lock.lock();
m_model->beginResetModel();
}
PartitionModel::ResetHelper::~ResetHelper()
{
// We need to unlock the mutex before emitting the reset signal,
// because the reset will cause clients to start looking at the
// (new) data.
m_model->m_lock.unlock();
m_model->endResetModel();
}
@ -58,6 +63,7 @@ PartitionModel::PartitionModel( QObject* parent )
void
PartitionModel::init( Device* device , const OsproberEntryList& osproberEntries )
{
QMutexLocker lock(&m_lock);
beginResetModel();
m_device = device;
m_osproberEntries = osproberEntries;
@ -271,6 +277,7 @@ PartitionModel::headerData( int section, Qt::Orientation, int role ) const
Partition*
PartitionModel::partitionForIndex( const QModelIndex& index ) const
{
QMutexLocker lock(&m_lock);
if ( !index.isValid() )
return nullptr;
return reinterpret_cast< Partition* >( index.internalPointer() );

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
* Copyright 2017, 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,6 +23,7 @@
// Qt
#include <QAbstractItemModel>
#include <QMutex>
class Device;
class Partition;
@ -115,8 +116,11 @@ public:
void update();
private:
friend class ResetHelper;
Device* m_device;
OsproberEntryList m_osproberEntries;
mutable QMutex m_lock;
};
#endif /* PARTITIONMODEL_H */

@ -2,7 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018-2019 Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

@ -2,7 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018-2019, Adriaan de Groot <groot@kde.org>
* Copyright 2018, Andrius Štikonas <andrius@stikonas.eu>
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
* Copyright 2019, Collabora Ltd
@ -512,7 +512,8 @@ findBootloader( const QAbstractItemModel* model, const QString& path )
for ( int i = 0; i < model->rowCount(); ++i)
{
const auto index = model->index( i, 0, QModelIndex() );
cDebug() << i << model->itemData( index );
if ( !index.isValid() )
continue;
QVariant var = model->data( index, BootLoaderModel::BootLoaderPathRole );
if ( var.isValid() && var.toString() == path )
return i;

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018-2019, Adriaan de Groot <groot@kde.org>
* Copyright 2019, Collabora Ltd
*
* Calamares is free software: you can redistribute it and/or modify

@ -2,7 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018-2019, Adriaan de Groot <groot@kde.org>
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
*
* Calamares is free software: you can redistribute it and/or modify
@ -60,8 +60,6 @@
#include <QtConcurrent/QtConcurrent>
#include <QFutureWatcher>
#include <unistd.h> // For sleep(3)
PartitionViewStep::PartitionViewStep( QObject* parent )
: Calamares::ViewStep( parent )
, m_core( nullptr )
@ -92,15 +90,16 @@ void
PartitionViewStep::continueLoading()
{
Q_ASSERT( !m_choicePage );
Q_ASSERT( !m_manualPartitionPage );
m_manualPartitionPage = new PartitionPage( m_core );
m_choicePage = new ChoicePage( m_swapChoices );
m_choicePage->init( m_core );
m_widget->addWidget( m_choicePage );
m_widget->addWidget( m_manualPartitionPage );
// Instantiate the manual partitioning page as needed.
//
Q_ASSERT( !m_manualPartitionPage );
// m_manualPartitionPage = new PartitionPage( m_core );
// m_widget->addWidget( m_manualPartitionPage );
m_widget->removeWidget( m_waitingWidget );
m_waitingWidget->deleteLater();
m_waitingWidget = nullptr;
@ -289,6 +288,12 @@ PartitionViewStep::next()
{
if ( m_choicePage->currentChoice() == ChoicePage::Manual )
{
if ( !m_manualPartitionPage )
{
m_manualPartitionPage = new PartitionPage( m_core );
m_widget->addWidget( m_manualPartitionPage );
}
m_widget->setCurrentWidget( m_manualPartitionPage );
m_manualPartitionPage->selectDeviceByIndex( m_choicePage->lastSelectedDeviceIndex() );
if ( m_core->isDirty() )
@ -306,6 +311,12 @@ PartitionViewStep::back()
{
m_widget->setCurrentWidget( m_choicePage );
m_choicePage->setLastSelectedDeviceIndex( m_manualPartitionPage->selectedDeviceIndex() );
if ( m_manualPartitionPage )
{
m_manualPartitionPage->deleteLater();
m_manualPartitionPage = nullptr;
}
}
}
@ -313,10 +324,10 @@ PartitionViewStep::back()
bool
PartitionViewStep::isNextEnabled() const
{
if ( m_choicePage && m_choicePage == m_widget->currentWidget() )
if ( m_choicePage && m_widget->currentWidget() == m_choicePage )
return m_choicePage->isNextEnabled();
if ( m_manualPartitionPage && m_manualPartitionPage == m_widget->currentWidget() )
if ( m_manualPartitionPage && m_widget->currentWidget() == m_manualPartitionPage )
return m_core->hasRootMountPoint();
return false;
@ -333,7 +344,7 @@ PartitionViewStep::isBackEnabled() const
bool
PartitionViewStep::isAtBeginning() const
{
if ( m_widget->currentWidget() == m_manualPartitionPage )
if ( m_widget->currentWidget() != m_choicePage )
return false;
return true;
}
@ -342,7 +353,7 @@ PartitionViewStep::isAtBeginning() const
bool
PartitionViewStep::isAtEnd() const
{
if ( m_choicePage == m_widget->currentWidget() )
if ( m_widget->currentWidget() == m_choicePage )
{
if ( m_choicePage->currentChoice() == ChoicePage::Erase ||
m_choicePage->currentChoice() == ChoicePage::Replace ||

@ -2,6 +2,7 @@
*
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -29,8 +30,8 @@
#include <QSpinBox>
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog( LvmDevice *device,
QVector< const Partition* > availablePVs,
QVector< const Partition* >& selectedPVs,
const PartitionVector& availablePVs,
PartitionVector& selectedPVs,
QWidget* parent )
: VolumeGroupBaseDialog( device->name(), device->physicalVolumes(), parent )
, m_selectedPVs( selectedPVs )

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,15 +27,17 @@ class LvmDevice;
class ResizeVolumeGroupDialog : public VolumeGroupBaseDialog
{
public:
using PartitionVector = QVector< const Partition* >;
ResizeVolumeGroupDialog( LvmDevice *device,
QVector< const Partition* > availablePVs,
QVector< const Partition* >& selectedPVs,
const PartitionVector& availablePVs,
PartitionVector& selectedPVs,
QWidget* parent );
void accept() override;
private:
QVector< const Partition* >& m_selectedPVs;
PartitionVector& m_selectedPVs;
};
#endif // RESIZEVOLUMEGROUPDIALOG_H

@ -2,7 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
* Copyright 2017, 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
* Copyright 2017, 2019 Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

Loading…
Cancel
Save