#include <QtQml/private/qquicklistmodel_p.h>
#include <QtQml/private/qqmlvaluetype_p.h>
#include <QStringListModel>
-#include <QStandardItemModel>
#include <QFile>
#include "../../shared/util.h"
Q_DECLARE_METATYPE(QQuickPathView::HighlightRangeMode)
+#ifndef QT_NO_WIDGETS
+#include <QStandardItemModel>
static void initStandardTreeModel(QStandardItemModel *model)
{
QStandardItem *item;
item->setIcon(QIcon());
model->insertRow(2, item);
}
+#endif
class tst_QQuickPathView : public QQmlDataTest
void visualDataModel();
void undefinedPath();
void mouseDrag();
+#ifndef QT_NO_WIDGETS
void treeModel();
+#endif
void changePreferredHighlight();
void missingPercent();
void creationContext();
delete canvas;
}
+#ifndef QT_NO_WIDGETS
void tst_QQuickPathView::treeModel()
{
QQuickView *canvas = createView();
delete canvas;
}
+#endif
void tst_QQuickPathView::changePreferredHighlight()
{
#include <qtest.h>
#include <QtTest/QSignalSpy>
-#include <QStandardItemModel>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQml/qqmlcontext.h>
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 DataObject : public QObject
{
};
QML_DECLARE_TYPE(SingleRoleModel)
+QML_DECLARE_TYPE(DataObject)
+#ifndef QT_NO_WIDGETS
QML_DECLARE_TYPE(StandardItem)
QML_DECLARE_TYPE(StandardItemModel)
-QML_DECLARE_TYPE(DataObject)
+#endif
class tst_qquickvisualdatamodel : public QQmlDataTest
{
private slots:
void initTestCase();
void cleanupTestCase();
+#ifndef QT_NO_WIDGETS
void rootIndex();
void updateLayout_data();
void updateLayout();
void childChanged_data();
void childChanged();
- void objectListModel();
- void singleRole();
- void modelProperties();
void noDelegate_data();
void noDelegate();
void itemsDestroyed_data();
void itemsDestroyed();
+#endif
+ void objectListModel();
+ void singleRole();
+ void modelProperties();
void packagesDestroyed();
void qaimRowsMoved();
void qaimRowsMoved_data();
qRegisterMetaType<QQuickChangeSet>();
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");
- qmlRegisterType<DataObject>("tst_qquickvisualdatamodel", 1, 0, "DataObject");
+#endif
}
void tst_qquickvisualdatamodel::cleanupTestCase()
{
}
+#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]