2019-01-07 17:25:22 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
|
|
|
*
|
2019-04-17 18:40:30 +02:00
|
|
|
* Copyright 2018-2019, Collabora Ltd <arnaud.ferraris@collabora.com>
|
2019-02-11 23:14:39 +01:00
|
|
|
* Copyright 2019, Adriaan de Groot <groot@kde.org>
|
2019-01-07 17:25:22 +01:00
|
|
|
*
|
|
|
|
* 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 PARTITIONLAYOUT_H
|
|
|
|
#define PARTITIONLAYOUT_H
|
|
|
|
|
2019-05-08 19:26:31 +02:00
|
|
|
#include "partition/PartitionSize.h"
|
|
|
|
|
2019-02-28 13:18:02 +01:00
|
|
|
#include "core/PartUtils.h"
|
|
|
|
|
2019-01-07 17:25:22 +01:00
|
|
|
// KPMcore
|
|
|
|
#include <kpmcore/core/partitiontable.h>
|
2019-02-22 18:42:16 +01:00
|
|
|
#include <kpmcore/fs/filesystem.h>
|
2019-01-07 17:25:22 +01:00
|
|
|
|
|
|
|
// Qt
|
|
|
|
#include <QList>
|
|
|
|
#include <QObject>
|
2020-03-16 22:25:55 +01:00
|
|
|
#include <QVariantMap>
|
2019-01-07 17:25:22 +01:00
|
|
|
|
|
|
|
class Partition;
|
|
|
|
|
|
|
|
class PartitionLayout
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct PartitionEntry
|
|
|
|
{
|
|
|
|
QString partLabel;
|
2020-03-19 13:37:21 +01:00
|
|
|
QString partType;
|
2019-01-07 17:25:22 +01:00
|
|
|
QString partMountPoint;
|
2019-02-22 18:42:16 +01:00
|
|
|
FileSystem::Type partFileSystem = FileSystem::Unknown;
|
2020-03-16 22:25:55 +01:00
|
|
|
QVariantMap partFeatures;
|
2019-05-14 11:52:58 +02:00
|
|
|
CalamaresUtils::Partition::PartitionSize partSize;
|
|
|
|
CalamaresUtils::Partition::PartitionSize partMinSize;
|
|
|
|
CalamaresUtils::Partition::PartitionSize partMaxSize;
|
2019-02-11 23:37:14 +01:00
|
|
|
|
|
|
|
/// @brief All-zeroes PartitionEntry
|
2019-04-15 16:06:21 +02:00
|
|
|
PartitionEntry() {}
|
2019-04-08 12:19:35 +02:00
|
|
|
/// @brief Parse @p size, @p min and @p max to their respective member variables
|
|
|
|
PartitionEntry( const QString& size, const QString& min, const QString& max );
|
2019-04-17 19:16:48 +02:00
|
|
|
|
|
|
|
bool isValid() const
|
|
|
|
{
|
2020-02-14 11:15:57 +01:00
|
|
|
if ( !partSize.isValid()
|
|
|
|
|| ( partMinSize.isValid() && partMaxSize.isValid() && partMinSize > partMaxSize ) )
|
|
|
|
{
|
2019-04-17 19:16:48 +02:00
|
|
|
return false;
|
2020-02-14 11:15:57 +01:00
|
|
|
}
|
2019-04-17 19:16:48 +02:00
|
|
|
return true;
|
|
|
|
}
|
2019-01-07 17:25:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
PartitionLayout();
|
|
|
|
PartitionLayout( PartitionEntry entry );
|
|
|
|
PartitionLayout( const PartitionLayout& layout );
|
|
|
|
~PartitionLayout();
|
|
|
|
|
2019-04-17 19:16:48 +02:00
|
|
|
bool addEntry( PartitionEntry entry );
|
2020-02-14 11:15:57 +01:00
|
|
|
bool addEntry( const QString& mountPoint,
|
|
|
|
const QString& size,
|
|
|
|
const QString& min = QString(),
|
|
|
|
const QString& max = QString() );
|
|
|
|
bool addEntry( const QString& label,
|
2020-03-19 13:37:21 +01:00
|
|
|
const QString& type,
|
2020-02-14 11:15:57 +01:00
|
|
|
const QString& mountPoint,
|
|
|
|
const QString& fs,
|
2020-03-16 22:25:55 +01:00
|
|
|
const QVariantMap& features,
|
2020-02-14 11:15:57 +01:00
|
|
|
const QString& size,
|
|
|
|
const QString& min = QString(),
|
|
|
|
const QString& max = QString() );
|
2019-01-07 17:25:22 +01:00
|
|
|
|
2019-01-07 17:26:37 +01:00
|
|
|
/**
|
|
|
|
* @brief Apply the current partition layout to the selected drive space.
|
|
|
|
* @return A list of Partition objects.
|
|
|
|
*/
|
2020-02-14 11:15:57 +01:00
|
|
|
QList< Partition* > execute( Device* dev,
|
|
|
|
qint64 firstSector,
|
|
|
|
qint64 lastSector,
|
|
|
|
QString luksPassphrase,
|
|
|
|
PartitionNode* parent,
|
|
|
|
const PartitionRole& role );
|
2019-01-07 17:26:37 +01:00
|
|
|
|
2019-01-07 17:25:22 +01:00
|
|
|
private:
|
2019-02-22 18:42:16 +01:00
|
|
|
FileSystem::Type m_defaultFsType;
|
2019-02-22 13:08:59 +01:00
|
|
|
QList< PartitionEntry > m_partLayout;
|
2019-01-07 17:25:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* PARTITIONLAYOUT_H */
|