mirror of
https://github.com/qmlnet/qmlnet.git
synced 2026-05-21 14:55:34 -06:00
Added methods to retrieve data from NetListModel
This commit is contained in:
parent
adc861aa42
commit
bc08cc2725
2 changed files with 17 additions and 0 deletions
|
|
@ -52,3 +52,17 @@ QHash<int,QByteArray> NetListModel::roleNames() const
|
|||
roles[0] = "modelData";
|
||||
return roles;
|
||||
}
|
||||
|
||||
QVariant NetListModel::at(int index)
|
||||
{
|
||||
QSharedPointer<NetVariant> result = _facade->getIndexed(_reference, static_cast<uint>(index));
|
||||
if(result == nullptr) {
|
||||
return QVariant();
|
||||
}
|
||||
return result->toQVariant();
|
||||
}
|
||||
|
||||
int NetListModel::length()
|
||||
{
|
||||
return static_cast<int>(_facade->getLength(_reference));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ public:
|
|||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
QHash<int,QByteArray> roleNames() const;
|
||||
|
||||
Q_INVOKABLE QVariant at(int index);
|
||||
Q_INVOKABLE int length();
|
||||
|
||||
private:
|
||||
QSharedPointer<NetTypeArrayFacade> _facade;
|
||||
QSharedPointer<NetReference> _reference;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue