mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-25 03:15:44 -05:00
[libcalamares] Satisfy test, return region names
This commit is contained in:
parent
609ea8350c
commit
33e39b92fb
3 changed files with 29 additions and 2 deletions
|
@ -255,13 +255,14 @@ LocaleTests::testRegions()
|
|||
QStringList names;
|
||||
for ( int i = 0; i < regions.rowCount( QModelIndex() ); ++i )
|
||||
{
|
||||
QVariant name = regions.data( regions.index( i ), Qt::UserRole );
|
||||
QVariant name = regions.data( regions.index( i ), Qt::DisplayRole );
|
||||
QVERIFY( name.isValid() );
|
||||
QVERIFY( !name.toString().isEmpty() );
|
||||
names.append( name.toString() );
|
||||
}
|
||||
|
||||
QVERIFY( names.contains( "America" ) );
|
||||
QVERIFY( !names.contains( "UTC" ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -326,9 +326,29 @@ RegionsModel::rowCount( const QModelIndex& parent ) const
|
|||
QVariant
|
||||
RegionsModel::data( const QModelIndex& index, int role ) const
|
||||
{
|
||||
if ( !index.isValid() || index.row() < 0 || index.row() >= m_private->m_regions.count() )
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if ( role == Qt::DisplayRole )
|
||||
{
|
||||
return m_private->m_regions[ index.row() ].tr();
|
||||
}
|
||||
if ( role == KeyRole )
|
||||
{
|
||||
return m_private->m_regions[ index.row() ].key();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QHash< int, QByteArray >
|
||||
RegionsModel::roleNames() const
|
||||
{
|
||||
return { { Qt::DisplayRole, "name" }, { KeyRole, "key" } };
|
||||
}
|
||||
|
||||
|
||||
ZonesModel::ZonesModel( QObject* parent )
|
||||
: QAbstractListModel( parent )
|
||||
, m_private( privateInstance() )
|
||||
|
|
|
@ -43,14 +43,20 @@ class DLLEXPORT RegionsModel : public QAbstractListModel
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
enum Roles
|
||||
{
|
||||
KeyRole = Qt::UserRole + 1
|
||||
};
|
||||
|
||||
RegionsModel( QObject* parent = nullptr );
|
||||
virtual ~RegionsModel() override;
|
||||
|
||||
int rowCount( const QModelIndex& parent ) const override;
|
||||
QVariant data( const QModelIndex& index, int role ) const override;
|
||||
|
||||
QHash< int, QByteArray > roleNames() const override;
|
||||
|
||||
private:
|
||||
Private* m_private;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue