171 - Validate address
This commit is contained in:
committed by
Aditya Kulkarni
parent
df1cbe6570
commit
1219651f76
37
src/validateaddress.cpp
Normal file
37
src/validateaddress.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "validateaddress.h"
|
||||
|
||||
|
||||
ValidateAddressesModel::ValidateAddressesModel(QTableView *parent, QList<QPair<QString, QString>> props)
|
||||
: QAbstractTableModel(parent) {
|
||||
headers << tr("Property") << tr("Value");
|
||||
this->props = props;
|
||||
}
|
||||
|
||||
|
||||
int ValidateAddressesModel::rowCount(const QModelIndex&) const {
|
||||
return props.size();
|
||||
}
|
||||
|
||||
int ValidateAddressesModel::columnCount(const QModelIndex&) const {
|
||||
return headers.size();
|
||||
}
|
||||
|
||||
QVariant ValidateAddressesModel::data(const QModelIndex &index, int role) const {
|
||||
QPair<QString, QString> p = props.at(index.row());
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch(index.column()) {
|
||||
case 0: return p.first;
|
||||
case 1: return p.second;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
QVariant ValidateAddressesModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
||||
return headers.at(section);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
Reference in New Issue
Block a user