d->component = comp;
d->ownComponent = false;
if (!d->component) {
- emit sourceChanged();
+ emit sourceComponentChanged();
emit statusChanged();
emit progressChanged();
emit itemChanged();
q, SIGNAL(progressChanged()));
emit q->statusChanged();
emit q->progressChanged();
- emit q->sourceChanged();
+ if (ownComponent)
+ emit q->sourceChanged();
+ else
+ emit q->sourceComponentChanged();
emit q->itemChanged();
}
}
if (component) {
if (!component->errors().isEmpty()) {
QDeclarativeEnginePrivate::warning(qmlEngine(q), component->errors());
- emit q->sourceChanged();
+ if (ownComponent)
+ emit q->sourceChanged();
+ else
+ emit q->sourceComponentChanged();
emit q->statusChanged();
emit q->progressChanged();
return;
source = QUrl();
}
component->completeCreate();
- emit q->sourceChanged();
+ if (ownComponent)
+ emit q->sourceChanged();
+ else
+ emit q->sourceComponentChanged();
emit q->statusChanged();
emit q->progressChanged();
emit q->itemChanged();
Q_ENUMS(Status)
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(QDeclarativeComponent *sourceComponent READ sourceComponent WRITE setSourceComponent RESET resetSourceComponent NOTIFY sourceChanged)
+ Q_PROPERTY(QDeclarativeComponent *sourceComponent READ sourceComponent WRITE setSourceComponent RESET resetSourceComponent NOTIFY sourceComponentChanged)
Q_PROPERTY(QSGItem *item READ item NOTIFY itemChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
public:
- QSGLoader(QSGItem *parent=0);
+ QSGLoader(QSGItem *parent = 0);
virtual ~QSGLoader();
QUrl source() const;
Q_SIGNALS:
void itemChanged();
void sourceChanged();
+ void sourceComponentChanged();
void statusChanged();
void progressChanged();
void loaded();
void tst_QSGLoader::sourceOrComponent()
{
+ QFETCH(QString, sourceOrComponent);
QFETCH(QString, sourceDefinition);
QFETCH(QUrl, sourceUrl);
QFETCH(QString, errorString);
"Loader {\n"
" property int onItemChangedCount: 0\n"
" property int onSourceChangedCount: 0\n"
+ " property int onSourceComponentChangedCount: 0\n"
" property int onStatusChangedCount: 0\n"
" property int onProgressChangedCount: 0\n"
" property int onLoadedCount: 0\n")
+ QByteArray(
" onItemChanged: onItemChangedCount += 1\n"
" onSourceChanged: onSourceChangedCount += 1\n"
+ " onSourceComponentChanged: onSourceComponentChangedCount += 1\n"
" onStatusChanged: onStatusChangedCount += 1\n"
" onProgressChanged: onProgressChangedCount += 1\n"
" onLoaded: onLoadedCount += 1\n"
QCOMPARE(loader->sourceComponent(), c);
}
- QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1);
+ if (sourceOrComponent == "component") {
+ QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 1);
+ QCOMPARE(loader->property("onSourceChangedCount").toInt(), 0);
+ } else {
+ QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 0);
+ QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1);
+ }
QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1);
QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1);
void tst_QSGLoader::sourceOrComponent_data()
{
+ QTest::addColumn<QString>("sourceOrComponent");
QTest::addColumn<QString>("sourceDefinition");
QTest::addColumn<QUrl>("sourceUrl");
QTest::addColumn<QString>("errorString");
- QTest::newRow("source") << "source: 'Rect120x60.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml") << "";
- QTest::newRow("sourceComponent") << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << "";
-
- QTest::newRow("invalid source") << "source: 'IDontExist.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml")
+ QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml") << "";
+ QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << "";
+ QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml")
<< QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found");
}