wip
This commit is contained in:
parent
4321a18fa6
commit
3fb5073aff
|
@ -551,6 +551,18 @@ DOS_API void DOS_CALL dos_qabstractitemmodel_dataChanged(DosQAbstractItemModel *
|
|||
/// \brief Calls the createIndex function
|
||||
DOS_API DosQModelIndex* DOS_CALL dos_qabstractitemmodel_createIndex(DosQAbstractItemModel *vptr,
|
||||
int row, int column, void *data = 0);
|
||||
|
||||
|
||||
DOS_API int DOS_CALL dos_qabstractitemmodel_rowCount(DosQAbstractItemModel *vptr, DosQModelIndex* parent);
|
||||
DOS_API int DOS_CALL dos_qabstractitemmodel_columnCount(DosQAbstractItemModel *vptr, DosQModelIndex* parent);
|
||||
DOS_API DosQVariant* DOS_CALL dos_qabstractitemmodel_data(DosQAbstractItemModel *vptr, DosQModelIndex* index, int role);
|
||||
DOS_API bool DOS_CALL dos_qabstractitemmodel_setData(DosQAbstractItemModel *vptr, DosQModelIndex* index, DosQVariant* value, int role);
|
||||
DOS_API DosQHashIntQByteArray* DOS_CALL dos_qabstractitemmodel_roleNames(DosQAbstractItemModel *vptr);
|
||||
DOS_API int DOS_CALL dos_qabstractitemmodel_flags(DosQAbstractItemModel *vptr, DosQModelIndex* index);
|
||||
DOS_API DosQVariant* DOS_CALL dos_qabstractitemmodel_headerData(DosQAbstractItemModel *vptr, int section, int orienation, int role);
|
||||
DOS_API DosQModelIndex* DOS_CALL dos_qabstractitemmodel_index(DosQAbstractItemModel *vptr, int row, int column, DosQModelIndex* parent);
|
||||
DOS_API DosQModelIndex* DOS_CALL dos_qabstractitemmodel_parent(DosQAbstractItemModel *vptr, DosQModelIndex* child);
|
||||
|
||||
/// @}
|
||||
|
||||
|
||||
|
|
|
@ -18,25 +18,25 @@ public:
|
|||
virtual ~DosIQAbstractItemModelImpl() = default;
|
||||
|
||||
/// @see QAbstractListModel::rowCount
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const = 0;
|
||||
virtual int defaultRowCount(const QModelIndex &parent = QModelIndex()) const = 0;
|
||||
|
||||
/// @see QAbstractListModel::columnCount
|
||||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;
|
||||
virtual int defaultColumnCount(const QModelIndex &parent = QModelIndex()) const = 0;
|
||||
|
||||
/// @see QAbstractListModel::data
|
||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const = 0;
|
||||
virtual QVariant defaultData(const QModelIndex &index, int role = Qt::DisplayRole) const = 0;
|
||||
|
||||
/// @see QAbstractListModel::setData
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) = 0;
|
||||
virtual bool defaultSetData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) = 0;
|
||||
|
||||
/// @see QAbstractListModel::flags
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const = 0;
|
||||
virtual Qt::ItemFlags defaultFlags(const QModelIndex &index) const = 0;
|
||||
|
||||
/// @see QAbstractListModel::headerData
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const = 0;
|
||||
virtual QVariant defaultHeaderData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const = 0;
|
||||
|
||||
/// @see QAbstractListModel::roleNames
|
||||
virtual QHash<int, QByteArray> roleNames() const = 0;
|
||||
virtual QHash<int, QByteArray> defaultRoleNames() const = 0;
|
||||
|
||||
/// @see QAbstractListModel::beginInsertRows
|
||||
virtual void publicBeginInsertRows(const QModelIndex &index, int first, int last) = 0;
|
||||
|
|
|
@ -104,6 +104,14 @@ public:
|
|||
/// Expose createIndex
|
||||
QModelIndex publicCreateIndex(int row, int column, void *data = nullptr) const override;
|
||||
|
||||
int defaultRowCount(const QModelIndex &parent) const override;
|
||||
int defaultColumnCount(const QModelIndex &parent) const override;
|
||||
QVariant defaultData(const QModelIndex &index, int role) const override;
|
||||
bool defaultSetData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
Qt::ItemFlags defaultFlags(const QModelIndex &index) const override;
|
||||
QVariant defaultHeaderData(int section, Qt::Orientation orientation, int role) const override;
|
||||
QHash<int, QByteArray> defaultRoleNames() const override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<DosIQObjectImpl> m_impl;
|
||||
void *m_modelObject;
|
||||
|
|
|
@ -102,6 +102,27 @@ public:
|
|||
/// @see DosIQAbstractItemModelImpl::createIndex
|
||||
QModelIndex publicCreateIndex(int row, int column, void *data) const override;
|
||||
|
||||
/// @see DosIQAbstractItemModelImpl::defaultRowCount
|
||||
int defaultRowCount(const QModelIndex &parent) const override;
|
||||
|
||||
/// @see DosIQAbstractItemModelImpl::defaultColumnCount
|
||||
int defaultColumnCount(const QModelIndex &parent) const override;
|
||||
|
||||
/// @see DosIQAbstractItemModelImpl::defaultData
|
||||
QVariant defaultData(const QModelIndex &index, int role) const override;
|
||||
|
||||
/// @see DosIQAbstractItemModelImpl::defaultSetData
|
||||
bool defaultSetData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
/// @see DosIQAbstractItemModelImpl::defaultFlags
|
||||
Qt::ItemFlags defaultFlags(const QModelIndex &index) const override;
|
||||
|
||||
/// @see DosIQAbstractItemModelImpl::defaultHeaderData
|
||||
QVariant defaultHeaderData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
/// @see DosIQAbstractItemModelImpl::defaultRoleNames
|
||||
QHash<int, QByteArray> defaultRoleNames() const override;
|
||||
|
||||
private:
|
||||
void *m_dObject;
|
||||
DosQAbstractItemModel *m_impl;
|
||||
|
@ -128,23 +149,23 @@ DosQAbstractItemModelWrapper<N, M>::DosQAbstractItemModelWrapper(QObject *parent
|
|||
m_data.createDObject(m_id, static_cast<QObject *>(this), &m_dObject, &impl);
|
||||
beginResetModel();
|
||||
m_impl = dynamic_cast<DosQAbstractItemModel *>(static_cast<QObject *>(impl));
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsAboutToBeInserted, this, &DosQAbstractItemModelWrapper::beginInsertRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsInserted, this, &DosQAbstractItemModelWrapper::endInsertRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsAboutToBeRemoved, this, &DosQAbstractItemModelWrapper::beginRemoveRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsRemoved, this, &DosQAbstractItemModelWrapper::endRemoveRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsAboutToBeMoved, this, &DosQAbstractItemModelWrapper::beginMoveRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsMoved, this, &DosQAbstractItemModelWrapper::endMoveRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsAboutToBeInserted, this, &DosQAbstractItemModelWrapper::beginInsertColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsInserted, this, &DosQAbstractItemModelWrapper::endInsertColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsAboutToBeRemoved, this, &DosQAbstractItemModelWrapper::beginRemoveColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsRemoved, this, &DosQAbstractItemModelWrapper::endRemoveColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsAboutToBeMoved, this, &DosQAbstractItemModelWrapper::beginMoveColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsMoved, this, &DosQAbstractItemModelWrapper::endMoveColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::modelAboutToBeReset, this, &DosQAbstractItemModelWrapper::beginResetModel);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::modelReset, this, &DosQAbstractItemModelWrapper::endResetModel);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::dataChanged, this, &DosQAbstractItemModelWrapper::dataChanged);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::layoutAboutToBeChanged, this, &DosQAbstractItemModelWrapper::layoutAboutToBeChanged);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::layoutChanged, this, &DosQAbstractItemModelWrapper::layoutChanged);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsAboutToBeInserted, this, &DosQAbstractItemModelWrapper<N,M>::beginInsertRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsInserted, this, &DosQAbstractItemModelWrapper<N,M>::endInsertRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsAboutToBeRemoved, this, &DosQAbstractItemModelWrapper<N,M>::beginRemoveRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsRemoved, this, &DosQAbstractItemModelWrapper<N,M>::endRemoveRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsAboutToBeMoved, this, &DosQAbstractItemModelWrapper<N,M>::beginMoveRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::rowsMoved, this, &DosQAbstractItemModelWrapper<N,M>::endMoveRows);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsAboutToBeInserted, this, &DosQAbstractItemModelWrapper<N,M>::beginInsertColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsInserted, this, &DosQAbstractItemModelWrapper<N,M>::endInsertColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsAboutToBeRemoved, this, &DosQAbstractItemModelWrapper<N,M>::beginRemoveColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsRemoved, this, &DosQAbstractItemModelWrapper<N,M>::endRemoveColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsAboutToBeMoved, this, &DosQAbstractItemModelWrapper<N,M>::beginMoveColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::columnsMoved, this, &DosQAbstractItemModelWrapper<N,M>::endMoveColumns);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::modelAboutToBeReset, this, &DosQAbstractItemModelWrapper<N,M>::beginResetModel);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::modelReset, this, &DosQAbstractItemModelWrapper<N,M>::endResetModel);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::dataChanged, this, &DosQAbstractItemModelWrapper<N,M>::dataChanged);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::layoutAboutToBeChanged, this, &DosQAbstractItemModelWrapper<N,M>::layoutAboutToBeChanged);
|
||||
QObject::connect(m_impl, &DosQAbstractItemModel::layoutChanged, this, &DosQAbstractItemModelWrapper<N,M>::layoutChanged);
|
||||
endResetModel();
|
||||
Q_ASSERT(m_dObject);
|
||||
Q_ASSERT(m_impl);
|
||||
|
@ -333,6 +354,48 @@ QModelIndex DosQAbstractItemModelWrapper<N, M>::publicCreateIndex(int row, int c
|
|||
return m_impl->publicCreateIndex(row, column, data);
|
||||
}
|
||||
|
||||
template<int N, int M>
|
||||
int DosQAbstractItemModelWrapper<N,M>::defaultRowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return m_impl->defaultRowCount(parent);
|
||||
}
|
||||
|
||||
template<int N, int M>
|
||||
int DosQAbstractItemModelWrapper<N,M>::defaultColumnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return m_impl->defaultColumnCount(parent);
|
||||
}
|
||||
|
||||
template<int N, int M>
|
||||
QVariant DosQAbstractItemModelWrapper<N,M>::defaultData(const QModelIndex &index, int role) const
|
||||
{
|
||||
return m_impl->defaultData(index, role);
|
||||
}
|
||||
|
||||
template<int N, int M>
|
||||
bool DosQAbstractItemModelWrapper<N,M>::defaultSetData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
return m_impl->defaultSetData(index, value, role);
|
||||
}
|
||||
|
||||
template<int N, int M>
|
||||
Qt::ItemFlags DosQAbstractItemModelWrapper<N,M>::defaultFlags(const QModelIndex &index) const
|
||||
{
|
||||
return m_impl->defaultFlags(index);
|
||||
}
|
||||
|
||||
template<int N, int M>
|
||||
QVariant DosQAbstractItemModelWrapper<N,M>::defaultHeaderData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
return m_impl->defaultHeaderData(section, orientation, role);
|
||||
}
|
||||
|
||||
template<int N, int M>
|
||||
QHash<int, QByteArray> DosQAbstractItemModelWrapper<N,M>::defaultRoleNames() const
|
||||
{
|
||||
return m_impl->defaultRoleNames();
|
||||
}
|
||||
|
||||
template<int N, int M>
|
||||
const QmlRegisterType &DosQAbstractItemModelWrapper<N, M>::qmlRegisterType()
|
||||
{
|
||||
|
|
|
@ -789,6 +789,13 @@ DosQModelIndex *dos_qabstractitemmodel_createIndex(::DosQAbstractItemModel *vptr
|
|||
return new QModelIndex(model->publicCreateIndex(row, column, data));
|
||||
}
|
||||
|
||||
int dos_qabstractitemmodel_rowCount(DosQAbstractItemModel *vptr, DosQModelIndex *parent)
|
||||
{
|
||||
auto object = static_cast<QObject *>(vptr);
|
||||
auto model = dynamic_cast<DOS::DosIQAbstractItemModelImpl *>(object);
|
||||
return model->defaultRowCount();
|
||||
}
|
||||
|
||||
int dos_qdeclarative_qmlregistertype(const ::QmlRegisterType *cArgs)
|
||||
{
|
||||
auto holder = static_cast<DOS::DosIQMetaObjectHolder *>(cArgs->staticMetaObject);
|
||||
|
|
|
@ -215,5 +215,5 @@ QModelIndex DosQAbstractGenericModel<T>::publicCreateIndex(int row, int column,
|
|||
|
||||
// Force instantiation
|
||||
template class DOS::DosQAbstractGenericModel<QAbstractItemModel>;
|
||||
template class DOS::DosQAbstractGenericModel<QAbstractListModel>;
|
||||
template class DOS::DosQAbstractGenericModel<QAbstractTableModel>;
|
||||
//template class DOS::DosQAbstractGenericModel<QAbstractListModel>;
|
||||
//template class DOS::DosQAbstractGenericModel<QAbstractTableModel>;
|
||||
|
|
Loading…
Reference in New Issue