2014-06-30 13:37:46 +02:00
|
|
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
|
|
|
*
|
|
|
|
* Copyright 2014, Aurélien Gâteau <agateau@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
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PARTITIONCOREMODULE_H
|
|
|
|
#define PARTITIONCOREMODULE_H
|
|
|
|
|
2014-07-11 16:55:21 +02:00
|
|
|
#include <PartitionModel.h>
|
2014-07-02 15:49:35 +02:00
|
|
|
#include <Typedefs.h>
|
2014-06-30 13:37:46 +02:00
|
|
|
|
2014-06-30 16:17:28 +02:00
|
|
|
// CalaPM
|
|
|
|
#include <core/partitiontable.h>
|
|
|
|
|
2014-07-02 15:49:35 +02:00
|
|
|
// Qt
|
|
|
|
#include <QList>
|
|
|
|
#include <QObject>
|
|
|
|
|
2014-06-30 18:08:13 +02:00
|
|
|
class CreatePartitionJob;
|
2014-06-30 13:37:46 +02:00
|
|
|
class Device;
|
2014-06-30 13:48:40 +02:00
|
|
|
class DeviceModel;
|
2014-06-30 16:17:28 +02:00
|
|
|
class FileSystem;
|
|
|
|
class Partition;
|
2014-06-30 13:37:46 +02:00
|
|
|
|
2014-07-22 10:42:50 +02:00
|
|
|
class QStandardItemModel;
|
|
|
|
|
2014-06-30 13:37:46 +02:00
|
|
|
/**
|
|
|
|
* Owns the Qt models and the PM devices
|
|
|
|
*/
|
|
|
|
class PartitionCoreModule : public QObject
|
|
|
|
{
|
2014-07-07 16:26:56 +02:00
|
|
|
Q_OBJECT
|
2014-06-30 13:37:46 +02:00
|
|
|
public:
|
2014-07-22 10:42:50 +02:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
BootLoaderPathRole = Qt::UserRole + 1
|
|
|
|
};
|
|
|
|
|
2014-06-30 13:37:46 +02:00
|
|
|
PartitionCoreModule( QObject* parent = nullptr );
|
2014-06-30 14:12:23 +02:00
|
|
|
~PartitionCoreModule();
|
2014-06-30 13:37:46 +02:00
|
|
|
|
2014-06-30 13:48:40 +02:00
|
|
|
DeviceModel* deviceModel() const;
|
|
|
|
|
2014-06-30 14:12:23 +02:00
|
|
|
PartitionModel* partitionModelForDevice( Device* device ) const;
|
|
|
|
|
2014-07-22 10:42:50 +02:00
|
|
|
QAbstractItemModel* bootLoaderModel() const;
|
|
|
|
|
2014-07-15 14:40:08 +02:00
|
|
|
void createPartitionTable( Device* device, PartitionTable::TableType type );
|
2014-07-10 19:55:16 +02:00
|
|
|
|
2014-07-16 16:20:58 +02:00
|
|
|
void createPartition( Device* device, Partition* partition );
|
2014-06-30 16:17:28 +02:00
|
|
|
|
2014-07-02 15:49:35 +02:00
|
|
|
void deletePartition( Device* device, Partition* partition );
|
|
|
|
|
2014-07-17 14:59:59 +02:00
|
|
|
void formatPartition( Device* device, Partition* partition );
|
|
|
|
|
2014-07-11 15:58:12 +02:00
|
|
|
QList< Calamares::job_ptr > jobs() const;
|
2014-07-02 16:06:54 +02:00
|
|
|
|
2014-07-07 16:26:56 +02:00
|
|
|
bool hasRootMountPoint() const
|
|
|
|
{
|
|
|
|
return m_hasRootMountPoint;
|
|
|
|
}
|
|
|
|
|
2014-07-17 14:26:40 +02:00
|
|
|
void refresh( Device* device );
|
|
|
|
|
2014-07-07 16:26:56 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void hasRootMountPointChanged( bool value );
|
|
|
|
|
2014-06-30 13:37:46 +02:00
|
|
|
private:
|
2014-07-11 16:55:21 +02:00
|
|
|
/**
|
2014-07-16 16:20:58 +02:00
|
|
|
* Owns the Device, PartitionModel and the jobs
|
2014-07-11 16:55:21 +02:00
|
|
|
*/
|
2014-07-16 16:20:58 +02:00
|
|
|
struct DeviceInfo
|
2014-07-11 15:58:12 +02:00
|
|
|
{
|
|
|
|
DeviceInfo( Device* );
|
2014-07-11 16:55:21 +02:00
|
|
|
~DeviceInfo();
|
2014-07-11 15:58:12 +02:00
|
|
|
QScopedPointer< Device > device;
|
|
|
|
QScopedPointer< PartitionModel > partitionModel;
|
|
|
|
QList< Calamares::job_ptr > jobs;
|
2014-07-11 16:55:21 +02:00
|
|
|
|
2014-07-11 17:08:56 +02:00
|
|
|
void forgetChanges();
|
2014-07-11 15:58:12 +02:00
|
|
|
};
|
|
|
|
QList< DeviceInfo* > m_deviceInfos;
|
|
|
|
|
2014-06-30 13:48:40 +02:00
|
|
|
DeviceModel* m_deviceModel;
|
2014-07-22 10:42:50 +02:00
|
|
|
QStandardItemModel* m_bootLoaderModel;
|
2014-07-07 16:26:56 +02:00
|
|
|
bool m_hasRootMountPoint = false;
|
2014-06-30 13:37:46 +02:00
|
|
|
|
|
|
|
void listDevices();
|
2014-07-10 19:01:55 +02:00
|
|
|
void updateHasRootMountPoint();
|
2014-07-10 18:55:19 +02:00
|
|
|
|
2014-07-02 15:49:35 +02:00
|
|
|
void dumpQueue() const;
|
2014-07-11 15:58:12 +02:00
|
|
|
|
|
|
|
DeviceInfo* infoForDevice( Device* ) const;
|
2014-07-22 10:42:50 +02:00
|
|
|
|
|
|
|
void updateBootLoaderModel();
|
|
|
|
|
|
|
|
Partition* findPartitionByMountPoint( const QString& mountPoint ) const;
|
2014-06-30 13:37:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* PARTITIONCOREMODULE_H */
|