1
0
Fork 0

Fix missed case in ModelDataExtractor

handle QList<QObject*> case, needed for location:airport runway
and parking selection. Thanks to Jonathan Redpath for the catch.
This commit is contained in:
James Turner 2018-11-06 18:06:46 +01:00
parent 41e9baaba1
commit 68813d1c57
2 changed files with 15 additions and 1 deletions

View file

@ -1,6 +1,7 @@
#include "ModelDataExtractor.hxx" #include "ModelDataExtractor.hxx"
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QDebug>
ModelDataExtractor::ModelDataExtractor(QObject *parent) : QObject(parent) ModelDataExtractor::ModelDataExtractor(QObject *parent) : QObject(parent)
{ {
@ -24,7 +25,15 @@ QVariant ModelDataExtractor::data() const
} }
if (m_value.isArray()) { if (m_value.isArray()) {
return m_value.property(m_index).toVariant(); quint32 uIndex = static_cast<quint32>(m_index);
auto v = m_value.property(uIndex);
if (v.isQObject()) {
// handle the QList<QObject*> case
auto obj = v.toQObject();
return obj->property(m_role.toUtf8().constData());
}
return m_value.property(uIndex).toVariant();
} }
return {}; return {};
@ -51,6 +60,8 @@ void ModelDataExtractor::setModel(QJSValue model)
this, &ModelDataExtractor::onDataChanged); this, &ModelDataExtractor::onDataChanged);
// ToDo: handle rows added / removed // ToDo: handle rows added / removed
} else {
qWarning() << "object but not a QAIM" << m_value.toQObject();
} }
} else { } else {
// might be null, or an array // might be null, or an array

View file

@ -38,6 +38,9 @@ Item {
if ((currentIndex == -1) && haveHeader()) if ((currentIndex == -1) && haveHeader())
return headerText; return headerText;
if (!currentItemText.data)
return "";
return currentItemText.data return currentItemText.data
} }