Fixed test and renaming

This commit is contained in:
Filippo Cucchetto 2017-03-05 19:30:57 +01:00
parent 259b8e4a48
commit 035c392e3e
7 changed files with 30 additions and 23 deletions

View File

@ -29,10 +29,10 @@ public:
/// @see IDynamicQObject::emitSignal
bool emitSignal(QObject *emitter, const QString &name, const std::vector<QVariant> &argumentsValues) override;
/// @see QAbstractListModel::metaObject()
/// @see QAbstractItemModel::metaObject()
const QMetaObject *metaObject() const override;
/// @see QAbstractListModel::qt_metacall
/// @see QAbstractItemModel::qt_metacall
int qt_metacall(QMetaObject::Call, int, void **) override;
/// Return the model's row count

View File

@ -37,25 +37,25 @@ public:
/// Sets the qmlRegisterType id
static void setId(int id);
/// @see QAbstractListModel::rowCount
/// @see QAbstractItemModel::rowCount
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
/// @see QAbstractListModel::columnCount
/// @see QAbstractItemModel::columnCount
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
/// @see QAbstractListModel::data
/// @see QAbstractItemModel::data
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
/// @see QAbstractListModel::setData
/// @see QAbstractItemModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
/// @see QAbstractListModel::flags
/// @see QAbstractItemModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override;
/// @see QAbstractListModel::headerData
/// @see QAbstractItemModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
/// @see QAbstractListModel::roleNames
/// @see QAbstractItemModel::roleNames
QHash<int, QByteArray> roleNames() const override;
/// @see QAbstractItemModel::index
@ -110,7 +110,7 @@ private:
};
template<int N, int M>
const QMetaObject DosQAbstractItemModelWrapper<N, M>::staticMetaObject = QAbstractListModel::staticMetaObject;
const QMetaObject DosQAbstractItemModelWrapper<N, M>::staticMetaObject = QAbstractItemModel::staticMetaObject;
template<int N, int M>
QmlRegisterType DosQAbstractItemModelWrapper<N, M>::m_data;
@ -339,7 +339,7 @@ const QmlRegisterType &DosQAbstractItemModelWrapper<N, M>::qmlRegisterType()
return m_data;
}
namespace DQALMW {
namespace DQAIMW {
template<int N>
using RegisterTypeQObject = DosQAbstractItemModelWrapper<N, 0>;

View File

@ -49,14 +49,14 @@ public:
DosQObjectMetaObject();
};
/// This is the DosQMetaObject for a QAbstractListModel
/// This is the DosQMetaObject for a QAbstractItemModel
class DosQAbstractItemModelMetaObject : public BaseDosQMetaObject
{
public:
DosQAbstractItemModelMetaObject();
};
/// This the generic version used by subclasses of QObject or QAbstractListModels
/// This the generic version used by subclasses of QObject or QAbstractItemModels
class DosQMetaObject : public BaseDosQMetaObject
{
public:

View File

@ -4,11 +4,11 @@
namespace DOS {
bool isQAbstractListModel(const QMetaObject *metaObject)
bool isQAbstractItemModel(const QMetaObject *metaObject)
{
const QMetaObject *current = metaObject;
while (current) {
if (&QAbstractListModel::staticMetaObject == current)
if (&QAbstractItemModel::staticMetaObject == current)
return true;
current = current->superClass();
}
@ -19,8 +19,8 @@ int dosQmlRegisterType(QmlRegisterType args)
{
static int i = 0;
static int j = 0;
if (isQAbstractListModel(args.staticMetaObject->metaObject()))
return DQALMW::DosQmlRegisterHelper<35>::Register(j++, std::move(args));
if (isQAbstractItemModel(args.staticMetaObject->metaObject()))
return DQAIMW::DosQmlRegisterHelper<35>::Register(j++, std::move(args));
else
return DQOW::DosQmlRegisterHelper<35>::Register(i++, std::move(args));
}
@ -29,8 +29,8 @@ int dosQmlRegisterSingletonType(QmlRegisterType args)
{
static int i = 0;
static int j = 0;
if (isQAbstractListModel(args.staticMetaObject->metaObject()))
return DQALMW::DosQmlRegisterSingletonHelper<35>::Register(j++, std::move(args));
if (isQAbstractItemModel(args.staticMetaObject->metaObject()))
return DQAIMW::DosQmlRegisterSingletonHelper<35>::Register(j++, std::move(args));
else
return DQOW::DosQmlRegisterSingletonHelper<35>::Register(i++, std::move(args));
}

View File

@ -3,7 +3,7 @@
#include "private/qmetaobjectbuilder_p.h"
#include "private/qmetaobject_p.h"
#include "private/qobject_p.h"
#include <QtCore/QAbstractListModel>
#include <QtCore/QAbstractItemModel>
namespace {

View File

@ -200,8 +200,15 @@ void MockQAbstractItemModel::onHeaderDataCalled(void *selfVPtr, int section, int
void MockQAbstractItemModel::onIndexCalled(void *selfVPtr, int row, int column, const DosQModelIndex *parent, DosQModelIndex *result)
{
auto self = static_cast<MockQAbstractItemModel*>(selfVPtr);
auto index = dos_qabstractitemmodel_createIndex(self->data(), row, column, 0);
dos_qmodelindex_assign(result, index);
dos_qmodelindex_delete(index);
}
void MockQAbstractItemModel::onParentCalled(void *selfVPtr, const DosQModelIndex *child, DosQModelIndex *result)
{
auto index = dos_qmodelindex_create();
dos_qmodelindex_assign(result, index);
dos_qmodelindex_delete(index);
}

View File

@ -424,9 +424,9 @@ private:
};
/*
* Test QAbstractListModel
* Test QAbstractItemModel
*/
class TestQAbstractListModel : public QObject
class TestQAbstractItemModel : public QObject
{
Q_OBJECT
@ -697,7 +697,7 @@ int main(int argc, char *argv[])
success &= ExecuteGuiTest<TestQQmlApplicationEngine>(argc, argv);
success &= ExecuteGuiTest<TestQQmlContext>(argc, argv);
success &= ExecuteGuiTest<TestQObject>(argc, argv);
success &= ExecuteGuiTest<TestQAbstractListModel>(argc, argv);
success &= ExecuteGuiTest<TestQAbstractItemModel>(argc, argv);
success &= ExecuteGuiTest<TestQDeclarativeIntegration>(argc, argv);
success &= ExecuteGuiTest<TestQQuickView>(argc, argv);
return success ? 0 : 1;