[libcalamares] Make explicit when a model comes from a file
This commit is contained in:
parent
afb5430c42
commit
01bba7b466
@ -101,13 +101,23 @@ TZZone::tr() const
|
||||
return QObject::tr( m_human, "tz_names" );
|
||||
}
|
||||
|
||||
TZRegionModel::TZRegionModel()
|
||||
{
|
||||
TZRegionModel::TZRegionModel() {}
|
||||
|
||||
QFile file( TZ_DATA_FILE );
|
||||
std::shared_ptr< TZRegionModel >
|
||||
TZRegionModel::fromZoneTab()
|
||||
{
|
||||
return TZRegionModel::fromFile( TZ_DATA_FILE );
|
||||
}
|
||||
|
||||
std::shared_ptr< TZRegionModel >
|
||||
TZRegionModel::fromFile( const char* fileName )
|
||||
{
|
||||
auto model = std::make_shared< TZRegionModel >();
|
||||
|
||||
QFile file( fileName );
|
||||
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||
{
|
||||
return;
|
||||
return model;
|
||||
}
|
||||
|
||||
QStringList regions;
|
||||
@ -147,11 +157,13 @@ TZRegionModel::TZRegionModel()
|
||||
}
|
||||
regions.sort();
|
||||
|
||||
m_regions.reserve( regions.length() );
|
||||
model->m_regions.reserve( regions.length() );
|
||||
for ( int i = 0; i < regions.length(); ++i )
|
||||
{
|
||||
m_regions.append( TZRegion( regions[ i ].toUtf8().data() ) );
|
||||
model->m_regions.append( TZRegion( regions[ i ].toUtf8().data() ) );
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
TZRegionModel::~TZRegionModel() {}
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace Locale
|
||||
@ -85,10 +87,15 @@ public:
|
||||
LabelRole = Qt::DisplayRole
|
||||
};
|
||||
|
||||
/// @brief Create from the zone.tab file
|
||||
/// @brief Create empty model (useless)
|
||||
TZRegionModel();
|
||||
virtual ~TZRegionModel() override;
|
||||
|
||||
/// @brief Create model from a zone.tab-like file
|
||||
static std::shared_ptr< TZRegionModel > fromFile( const char* fileName );
|
||||
/// @brief Calls fromFile with the standard zone.tab name
|
||||
static std::shared_ptr< TZRegionModel > fromZoneTab();
|
||||
|
||||
int rowCount( const QModelIndex& parent ) const override;
|
||||
|
||||
QVariant data( const QModelIndex& index, int role ) const override;
|
||||
|
Loading…
Reference in New Issue
Block a user