-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnationalitymodel.cpp
More file actions
43 lines (36 loc) · 1.06 KB
/
nationalitymodel.cpp
File metadata and controls
43 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "nationalitymodel.h"
NationalityModel::NationalityModel(QObject *parent) :
QAbstractListModel(parent)
{
m_content << qMakePair( DataPair::first_type(), DataPair::second_type( "" ) )
<< qMakePair( DataPair::first_type( "Russian" ), DataPair::second_type( "russian" ) )
<< qMakePair( DataPair::first_type( "Belgian" ), DataPair::second_type( "belgian" ) )
<< qMakePair( DataPair::first_type( "Norwegian" ), DataPair::second_type( "norwegian" ) )
<< qMakePair( DataPair::first_type( "American" ), DataPair::second_type( "american" ) )
<< qMakePair( DataPair::first_type( "German" ), DataPair::second_type( "german" ) );
}
QVariant NationalityModel::data( const QModelIndex &index, int role ) const
{
const DataPair& data = m_content.at( index.row() );
QVariant value;
switch ( role )
{
case Qt::DisplayRole:
{
value = data.first;
}
break;
case Qt::UserRole:
{
value = data.second;
}
break;
default:
break;
}
return value;
}
int NationalityModel::rowCount(const QModelIndex &/*parent*/) const
{
return m_content.count();
}