fix(wallet): Fetch preferences only when changed (#15024)
This commit is contained in:
parent
a93455c2d0
commit
0d3cb065fb
|
@ -38,13 +38,9 @@ ManageTokensController::ManageTokensController(QObject* parent)
|
||||||
for (int i = first; i <= last; i++)
|
for (int i = first; i <= last; i++)
|
||||||
addItem(i);
|
addItem(i);
|
||||||
|
|
||||||
rebuildCommunityTokenGroupsModel();
|
rebuildModels();
|
||||||
rebuildHiddenCommunityTokenGroupsModel();
|
|
||||||
rebuildCollectionGroupsModel();
|
|
||||||
rebuildHiddenCollectionGroupsModel();
|
|
||||||
|
|
||||||
for (auto model : m_allModels) {
|
for (auto model : m_allModels) {
|
||||||
model->applySort();
|
|
||||||
model->saveCustomSortOrder();
|
model->saveCustomSortOrder();
|
||||||
}
|
}
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
|
@ -52,12 +48,8 @@ ManageTokensController::ManageTokensController(QObject* parent)
|
||||||
<< "!!! ADDING NEW SOURCE DATA TOOK" << t.nsecsElapsed() / 1'000'000.f << "ms";
|
<< "!!! ADDING NEW SOURCE DATA TOOK" << t.nsecsElapsed() / 1'000'000.f << "ms";
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
connect(m_sourceModel, &QAbstractItemModel::rowsRemoved, this, &ManageTokensController::requestLoadSettings);
|
connect(m_sourceModel, &QAbstractItemModel::rowsRemoved, this, &ManageTokensController::parseSourceModel);
|
||||||
connect(m_sourceModel,
|
connect(m_sourceModel, &QAbstractItemModel::dataChanged, this, &ManageTokensController::parseSourceModel);
|
||||||
&QAbstractItemModel::dataChanged,
|
|
||||||
this,
|
|
||||||
&ManageTokensController::requestLoadSettings); // NB at this point we don't know in
|
|
||||||
// which submodel the item is
|
|
||||||
m_modelConnectionsInitialized = true;
|
m_modelConnectionsInitialized = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -335,12 +327,12 @@ void ManageTokensController::setSourceModel(QAbstractItemModel* newSourceModel)
|
||||||
|
|
||||||
m_sourceModel = newSourceModel;
|
m_sourceModel = newSourceModel;
|
||||||
|
|
||||||
connect(m_sourceModel, &QAbstractItemModel::modelReset, this, &ManageTokensController::requestLoadSettings);
|
connect(m_sourceModel, &QAbstractItemModel::modelReset, this, &ManageTokensController::parseSourceModel);
|
||||||
|
|
||||||
if (m_sourceModel && m_sourceModel->roleNames().isEmpty()) { // workaround for when a model has no roles and roles
|
if (m_sourceModel && m_sourceModel->roleNames().isEmpty()) { // workaround for when a model has no roles and roles
|
||||||
// are added when the model is populated (ListModel)
|
// are added when the model is populated (ListModel)
|
||||||
// QTBUG-57971
|
// QTBUG-57971
|
||||||
connect(m_sourceModel, &QAbstractItemModel::rowsInserted, this, &ManageTokensController::requestLoadSettings);
|
connect(m_sourceModel, &QAbstractItemModel::rowsInserted, this, &ManageTokensController::parseSourceModel);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
requestLoadSettings();
|
requestLoadSettings();
|
||||||
|
@ -352,7 +344,7 @@ void ManageTokensController::parseSourceModel()
|
||||||
if (!m_sourceModel)
|
if (!m_sourceModel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
disconnect(m_sourceModel, &QAbstractItemModel::rowsInserted, this, &ManageTokensController::requestLoadSettings);
|
disconnect(m_sourceModel, &QAbstractItemModel::rowsInserted, this, &ManageTokensController::parseSourceModel);
|
||||||
|
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
QElapsedTimer t;
|
QElapsedTimer t;
|
||||||
|
@ -370,6 +362,17 @@ void ManageTokensController::parseSourceModel()
|
||||||
addItem(i);
|
addItem(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rebuildModels();
|
||||||
|
|
||||||
|
#ifdef QT_DEBUG
|
||||||
|
qCDebug(manageTokens) << "!!! PARSING SOURCE DATA TOOK" << t.nsecsElapsed() / 1'000'000.f << "ms";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
emit sourceModelChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ManageTokensController::rebuildModels()
|
||||||
|
{
|
||||||
// build community groups model
|
// build community groups model
|
||||||
rebuildCommunityTokenGroupsModel();
|
rebuildCommunityTokenGroupsModel();
|
||||||
rebuildHiddenCommunityTokenGroupsModel();
|
rebuildHiddenCommunityTokenGroupsModel();
|
||||||
|
@ -383,12 +386,6 @@ void ManageTokensController::parseSourceModel()
|
||||||
model->applySort();
|
model->applySort();
|
||||||
model->setDirty(false);
|
model->setDirty(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef QT_DEBUG
|
|
||||||
qCDebug(manageTokens) << "!!! PARSING SOURCE DATA TOOK" << t.nsecsElapsed() / 1'000'000.f << "ms";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
emit sourceModelChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManageTokensController::addItem(int index)
|
void ManageTokensController::addItem(int index)
|
||||||
|
@ -693,4 +690,4 @@ void ManageTokensController::setSerializeAsCollectibles(const bool newSerializeA
|
||||||
return;
|
return;
|
||||||
m_serializeAsCollectibles = newSerializeAsCollectibles;
|
m_serializeAsCollectibles = newSerializeAsCollectibles;
|
||||||
emit serializeAsCollectiblesChanged();
|
emit serializeAsCollectiblesChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,7 @@ private:
|
||||||
QAbstractItemModel* sourceModel() const { return m_sourceModel; }
|
QAbstractItemModel* sourceModel() const { return m_sourceModel; }
|
||||||
void setSourceModel(QAbstractItemModel* newSourceModel);
|
void setSourceModel(QAbstractItemModel* newSourceModel);
|
||||||
void parseSourceModel();
|
void parseSourceModel();
|
||||||
|
void rebuildModels();
|
||||||
|
|
||||||
void addItem(int index);
|
void addItem(int index);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue