AutoTableModel now can display data from related table.
Usage example of ComboBox binding in Accommodation plugin.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "core_global.h"
|
||||
#include "exprevaluator.h"
|
||||
#include "itablemodel.h"
|
||||
#include "data/comboitem.h"
|
||||
|
||||
template<class T>
|
||||
class AutoTableModel : public ITableModel
|
||||
@@ -51,7 +52,13 @@ public:
|
||||
QSharedPointer<T> entity = m_list.at(index.row());
|
||||
QObject *rawEntity = (QObject*)entity.data();
|
||||
|
||||
return rawEntity->property(rawEntity->metaObject()->property(index.column() + 1).name());
|
||||
QVariant dispData = rawEntity->property(rawEntity->metaObject()->property(index.column() + 1).name());
|
||||
if (dispData.canConvert<QObject*>() && qobject_cast<ComboItem*>(dispData.value<QObject*>()))
|
||||
{
|
||||
return qobject_cast<ComboItem*>(dispData.value<QObject*>())->toString();
|
||||
}
|
||||
|
||||
return dispData;
|
||||
}
|
||||
|
||||
return QVariant::Invalid;
|
||||
|
||||
Reference in New Issue
Block a user