forked from qt-creator/qt-creator
QmlDesigner: Fix collection editor model list empty sometimes
Also few tweaks Change-Id: I6041c0b37aa5c576e0c4efc988ed15eae02d767f Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Ali Kianian <ali.kianian@qt.io>
This commit is contained in:
@@ -25,9 +25,8 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QJsonArray>
|
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -68,7 +67,6 @@ CollectionView::CollectionView(ExternalDependenciesInterface &externalDependenci
|
|||||||
if (m_widget.get())
|
if (m_widget.get())
|
||||||
m_widget->collectionDetailsModel()->removeAllCollections();
|
m_widget->collectionDetailsModel()->removeAllCollections();
|
||||||
});
|
});
|
||||||
resetDataStoreNode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CollectionView::hasWidget() const
|
bool CollectionView::hasWidget() const
|
||||||
@@ -226,9 +224,9 @@ void CollectionView::customNotification(const AbstractView *,
|
|||||||
m_widget->openCollection(collectionNameFromDataStoreChildren(data.first().toByteArray()));
|
m_widget->openCollection(collectionNameFromDataStoreChildren(data.first().toByteArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollectionView::addResource(const QUrl &url, const QString &name, const QString &type)
|
void CollectionView::addResource(const QUrl &url, const QString &name)
|
||||||
{
|
{
|
||||||
executeInTransaction(Q_FUNC_INFO, [this, &url, &name, &type]() {
|
executeInTransaction(Q_FUNC_INFO, [this, &url, &name]() {
|
||||||
ensureStudioModelImport();
|
ensureStudioModelImport();
|
||||||
QString sourceAddress;
|
QString sourceAddress;
|
||||||
if (url.isLocalFile()) {
|
if (url.isLocalFile()) {
|
||||||
@@ -319,7 +317,7 @@ void CollectionView::registerDeclarativeType()
|
|||||||
|
|
||||||
void CollectionView::resetDataStoreNode()
|
void CollectionView::resetDataStoreNode()
|
||||||
{
|
{
|
||||||
m_dataStore->reloadModel();
|
QTimer::singleShot(0, this, [&] { m_dataStore->reloadModel(); });
|
||||||
refreshModel();
|
refreshModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,7 +445,8 @@ void DelayedAssignCollectionToItem::checkAndAssign()
|
|||||||
bool dataStoreFound = false;
|
bool dataStoreFound = false;
|
||||||
|
|
||||||
if (m_collectionView->isDataStoreReady()) {
|
if (m_collectionView->isDataStoreReady()) {
|
||||||
for (const QmlTypeData &cppTypeData : view->rewriterView()->getQMLTypes()) {
|
const QList<QmlTypeData> types = view->rewriterView()->getQMLTypes();
|
||||||
|
for (const QmlTypeData &cppTypeData : types) {
|
||||||
if (cppTypeData.isSingleton && cppTypeData.typeName == "DataStore")
|
if (cppTypeData.isSingleton && cppTypeData.typeName == "DataStore")
|
||||||
dataStoreFound = true;
|
dataStoreFound = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
const QList<ModelNode> &nodeList,
|
const QList<ModelNode> &nodeList,
|
||||||
const QList<QVariant> &data) override;
|
const QList<QVariant> &data) override;
|
||||||
|
|
||||||
void addResource(const QUrl &url, const QString &name, const QString &type);
|
void addResource(const QUrl &url, const QString &name);
|
||||||
|
|
||||||
void assignCollectionToNode(const QString &collectionName, const ModelNode &node);
|
void assignCollectionToNode(const QString &collectionName, const ModelNode &node);
|
||||||
void assignCollectionToSelectedNode(const QString &collectionName);
|
void assignCollectionToSelectedNode(const QString &collectionName);
|
||||||
|
|||||||
@@ -153,14 +153,14 @@ bool CollectionWidget::loadJsonFile(const QUrl &url, const QString &collectionNa
|
|||||||
if (!isJsonFile(url))
|
if (!isJsonFile(url))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_view->addResource(url, getPreferredCollectionName(url, collectionName), "json");
|
m_view->addResource(url, getPreferredCollectionName(url, collectionName));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CollectionWidget::loadCsvFile(const QUrl &url, const QString &collectionName)
|
bool CollectionWidget::loadCsvFile(const QUrl &url, const QString &collectionName)
|
||||||
{
|
{
|
||||||
m_view->addResource(url, getPreferredCollectionName(url, collectionName), "csv");
|
m_view->addResource(url, getPreferredCollectionName(url, collectionName));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user