#include <private/qquickchangeset_p.h>
#include <private/qqmlengine_p.h>
#include <math.h>
+#include <QtGui/qstandarditemmodel.h>
using namespace QQuickVisualTestUtil;
using namespace QQuickViewTestUtil;
template <typename T, int N> int lengthOf(const T (&)[N]) { return N; }
-#ifndef QT_NO_WIDGETS
-#include <QStandardItemModel>
static void initStandardTreeModel(QStandardItemModel *model)
{
QStandardItem *item;
item->setIcon(QIcon());
model->insertRow(2, item);
}
-#endif
class SingleRoleModel : public QAbstractListModel
{
}
};
-#ifndef QT_NO_WIDGETS
class StandardItem : public QObject, public QStandardItem
{
Q_OBJECT
static_cast<QStandardItemModel *>(property->object)->appendRow(item);
}
};
-#endif
class DataSubObject : public QObject
{
QML_DECLARE_TYPE(SingleRoleModel)
QML_DECLARE_TYPE(DataObject)
-#ifndef QT_NO_WIDGETS
QML_DECLARE_TYPE(StandardItem)
QML_DECLARE_TYPE(StandardItemModel)
-#endif
class tst_qquickvisualdatamodel : public QQmlDataTest
{
private slots:
void initTestCase();
void cleanupTestCase();
-#ifndef QT_NO_WIDGETS
void rootIndex();
void updateLayout_data();
void updateLayout();
void noDelegate();
void itemsDestroyed_data();
void itemsDestroyed();
-#endif
void objectListModel();
void singleRole();
void modelProperties();
qmlRegisterType<SingleRoleModel>("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel");
qmlRegisterType<DataObject>("tst_qquickvisualdatamodel", 1, 0, "DataObject");
-#ifndef QT_NO_WIDGETS
qmlRegisterType<StandardItem>("tst_qquickvisualdatamodel", 1, 0, "StandardItem");
qmlRegisterType<StandardItemModel>("tst_qquickvisualdatamodel", 1, 0, "StandardItemModel");
-#endif
engine.setIncubationController(&controller);
}
{
}
-#ifndef QT_NO_WIDGETS
void tst_qquickvisualdatamodel::rootIndex()
{
QQmlEngine engine;
QVERIFY(name);
QCOMPARE(name->text(), QString("Row 3 Item"));
}
-#endif
void tst_qquickvisualdatamodel::objectListModel()
{
QCOMPARE(delegate->property("test8").toInt(),1);
}
-#ifndef QT_NO_WIDGETS
{
QQuickView view;
QCOMPARE(delegate->property("test7").toInt(),1);
QCOMPARE(delegate->property("test8").toInt(),1);
}
-#endif
//### should also test QStringList and QVariantList
}
-#ifndef QT_NO_WIDGETS
void tst_qquickvisualdatamodel::noDelegate_data()
{
QTest::addColumn<QUrl>("source");
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QVERIFY(!delegate);
}
-#endif
void tst_qquickvisualdatamodel::packagesDestroyed()
{
<< 4 << 5 << 0 << true << true << false << false << true
<< QString("name")
<< (QStringList() << "seven" << "one" << "two" << "three" << "four");
-#ifndef QT_NO_WIDGETS
+
// AbstractItemModel (Multiple Roles).
QTest::newRow("StandardItemModel.items prepend")
<< multipleRoleSource[i]
<< 4 << 5 << 0 << true << true << false << false << false
<< QString("display")
<< (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-#endif
+
// StringList.
QTest::newRow("StringList.items prepend")
<< stringListSource[i]
<< QString("name")
<< (QStringList() << "one" << "two" << "three" << "four");
-#ifndef QT_NO_WIDGETS
// AbstractItemModel (Multiple Roles)
QTest::newRow("StandardItemModel.items prepend, resolve prepended")
<< multipleRoleSource[i]
<< 5 << 4 << 4 << 2 << true << false << true << false << false
<< QString("display")
<< (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-#endif
+
// StringList
QTest::newRow("StringList.items prepend, resolve prepended")
<< stringListSource[i]