Introduce PartitionInfo, to store Calamares-specifc info for a partition
This commit is contained in:
parent
1247077ccc
commit
f3f9bfc2a3
@ -15,6 +15,7 @@ calamares_add_plugin( partition
|
|||||||
DeletePartitionJob.cpp
|
DeletePartitionJob.cpp
|
||||||
DeviceModel.cpp
|
DeviceModel.cpp
|
||||||
PartitionCoreModule.cpp
|
PartitionCoreModule.cpp
|
||||||
|
PartitionInfo.cpp
|
||||||
PartitionModel.cpp
|
PartitionModel.cpp
|
||||||
PartitionPage.cpp
|
PartitionPage.cpp
|
||||||
PartitionViewStep.cpp
|
PartitionViewStep.cpp
|
||||||
@ -36,6 +37,7 @@ set( partview_SRCS
|
|||||||
DeletePartitionJob.cpp
|
DeletePartitionJob.cpp
|
||||||
DeviceModel.cpp
|
DeviceModel.cpp
|
||||||
PartitionCoreModule.cpp
|
PartitionCoreModule.cpp
|
||||||
|
PartitionInfo.cpp
|
||||||
PartitionModel.cpp
|
PartitionModel.cpp
|
||||||
PartitionPage.cpp
|
PartitionPage.cpp
|
||||||
PMUtils.cpp
|
PMUtils.cpp
|
||||||
|
@ -38,7 +38,6 @@ PartitionCoreModule::DeviceInfo::DeviceInfo( Device* dev )
|
|||||||
: device( dev )
|
: device( dev )
|
||||||
, partitionModel( new PartitionModel )
|
, partitionModel( new PartitionModel )
|
||||||
{
|
{
|
||||||
partitionModel->init( dev );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PartitionCoreModule::DeviceInfo::~DeviceInfo()
|
PartitionCoreModule::DeviceInfo::~DeviceInfo()
|
||||||
@ -62,13 +61,16 @@ PartitionCoreModule::PartitionCoreModule( QObject* parent )
|
|||||||
m_deviceModel->init( lst );
|
m_deviceModel->init( lst );
|
||||||
for ( auto device : lst )
|
for ( auto device : lst )
|
||||||
{
|
{
|
||||||
m_devices << new DeviceInfo( device );
|
DeviceInfo* info = new DeviceInfo( device );
|
||||||
|
info->partitionModel->init( device, &m_infoForPartitionHash );
|
||||||
|
m_devices << info;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PartitionCoreModule::~PartitionCoreModule()
|
PartitionCoreModule::~PartitionCoreModule()
|
||||||
{
|
{
|
||||||
|
qDeleteAll( m_infoForPartitionHash );
|
||||||
qDeleteAll( m_devices );
|
qDeleteAll( m_devices );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +98,10 @@ PartitionCoreModule::createPartition( CreatePartitionJob* job )
|
|||||||
{
|
{
|
||||||
DeviceInfo* info = deviceInfoForDevice( job->device() );
|
DeviceInfo* info = deviceInfoForDevice( job->device() );
|
||||||
Q_ASSERT( info );
|
Q_ASSERT( info );
|
||||||
|
Q_ASSERT( !m_infoForPartitionHash.contains( job->partition() ) );
|
||||||
|
PartitionInfo* partitionInfo = new PartitionInfo( job->partition() );
|
||||||
|
partitionInfo->mountPoint = job->mountPoint();
|
||||||
|
m_infoForPartitionHash[ job->partition() ] = partitionInfo;
|
||||||
job->updatePreview();
|
job->updatePreview();
|
||||||
info->partitionModel->reload();
|
info->partitionModel->reload();
|
||||||
m_jobs << Calamares::job_ptr( job );
|
m_jobs << Calamares::job_ptr( job );
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#ifndef PARTITIONCOREMODULE_H
|
#ifndef PARTITIONCOREMODULE_H
|
||||||
#define PARTITIONCOREMODULE_H
|
#define PARTITIONCOREMODULE_H
|
||||||
|
|
||||||
|
#include <PartitionInfo.h>
|
||||||
#include <Typedefs.h>
|
#include <Typedefs.h>
|
||||||
|
|
||||||
// CalaPM
|
// CalaPM
|
||||||
@ -66,6 +67,7 @@ private:
|
|||||||
PartitionModel* partitionModel;
|
PartitionModel* partitionModel;
|
||||||
};
|
};
|
||||||
QList< DeviceInfo* > m_devices;
|
QList< DeviceInfo* > m_devices;
|
||||||
|
InfoForPartitionHash m_infoForPartitionHash;
|
||||||
DeviceModel* m_deviceModel;
|
DeviceModel* m_deviceModel;
|
||||||
|
|
||||||
QList< Calamares::job_ptr > m_jobs;
|
QList< Calamares::job_ptr > m_jobs;
|
||||||
|
22
src/modules/partition/PartitionInfo.cpp
Normal file
22
src/modules/partition/PartitionInfo.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/* === 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/>.
|
||||||
|
*/
|
||||||
|
#include <PartitionInfo.h>
|
||||||
|
|
||||||
|
PartitionInfo::PartitionInfo( Partition* p )
|
||||||
|
: partition( p )
|
||||||
|
{}
|
40
src/modules/partition/PartitionInfo.h
Normal file
40
src/modules/partition/PartitionInfo.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* === 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 PARTITIONINFO_H
|
||||||
|
#define PARTITIONINFO_H
|
||||||
|
|
||||||
|
#include <QHash>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class Partition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores Calamares-specific info about a partition.
|
||||||
|
* Does not own anything.
|
||||||
|
*/
|
||||||
|
struct PartitionInfo
|
||||||
|
{
|
||||||
|
explicit PartitionInfo( Partition* );
|
||||||
|
Partition* partition;
|
||||||
|
QString mountPoint;
|
||||||
|
bool format = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QHash< Partition*, PartitionInfo* > InfoForPartitionHash;
|
||||||
|
|
||||||
|
#endif /* PARTITIONINFO_H */
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <PartitionModel.h>
|
#include <PartitionModel.h>
|
||||||
|
|
||||||
|
#include <PartitionInfo.h>
|
||||||
#include <PMUtils.h>
|
#include <PMUtils.h>
|
||||||
#include <utils/Logger.h>
|
#include <utils/Logger.h>
|
||||||
|
|
||||||
@ -35,9 +36,10 @@ PartitionModel::PartitionModel( QObject* parent )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionModel::init( Device* device )
|
PartitionModel::init( Device* device, InfoForPartitionHash* infoForPartitionHash )
|
||||||
{
|
{
|
||||||
m_device = device;
|
m_device = device;
|
||||||
|
m_infoForPartitionHash = infoForPartitionHash;
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,15 +106,8 @@ PartitionModel::data( const QModelIndex& index, int role ) const
|
|||||||
}
|
}
|
||||||
if ( col == MountPointColumn )
|
if ( col == MountPointColumn )
|
||||||
{
|
{
|
||||||
QString mountPoint = partition->mountPoint();
|
PartitionInfo* info = m_infoForPartitionHash->value( partition );
|
||||||
if ( mountPoint.isEmpty() || mountPoint == "none" )
|
return info ? info->mountPoint : QString();
|
||||||
{
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return mountPoint;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ( col == SizeColumn )
|
if ( col == SizeColumn )
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
#ifndef PARTITIONMODEL_H
|
#ifndef PARTITIONMODEL_H
|
||||||
#define PARTITIONMODEL_H
|
#define PARTITIONMODEL_H
|
||||||
|
|
||||||
|
#include <PartitionInfo.h>
|
||||||
|
|
||||||
|
// Qt
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
@ -37,7 +40,11 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
PartitionModel( QObject* parent = 0 );
|
PartitionModel( QObject* parent = 0 );
|
||||||
void init( Device* device );
|
/**
|
||||||
|
* device and infoForPartitions must remain alive for the life of
|
||||||
|
* PartitionModel
|
||||||
|
*/
|
||||||
|
void init( Device* device, InfoForPartitionHash* infoForPartitionHash );
|
||||||
|
|
||||||
int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
|
int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
|
||||||
int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
|
int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
|
||||||
@ -57,6 +64,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Device* m_device;
|
Device* m_device;
|
||||||
|
InfoForPartitionHash* m_infoForPartitionHash;
|
||||||
QList< Partition* > m_partitionList;
|
QList< Partition* > m_partitionList;
|
||||||
|
|
||||||
void fillPartitionList( PartitionNode* parent );
|
void fillPartitionList( PartitionNode* parent );
|
||||||
|
Loading…
Reference in New Issue
Block a user