forked from qt-creator/qt-creator
QmlDesigner: Remove the optional func param from Model::generateNewId()
Not needed anymore after using UniqueName class. Change-Id: I252659376af7e8aaf5e4642f9b9bfd2c57cc19fb Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Marco Bubke <marco.bubke@qt.io> Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
This commit is contained in:
@@ -255,8 +255,7 @@ public:
|
|||||||
bool hasId(const QString &id) const;
|
bool hasId(const QString &id) const;
|
||||||
bool hasImport(const QString &importUrl) const;
|
bool hasImport(const QString &importUrl) const;
|
||||||
|
|
||||||
QString generateNewId(const QString &prefixName, const QString &fallbackPrefix = "element",
|
QString generateNewId(const QString &prefixName, const QString &fallbackPrefix = "element") const;
|
||||||
std::optional<std::function<bool(const QString &)>> isDuplicate = {}) const;
|
|
||||||
|
|
||||||
void startDrag(QMimeData *mimeData, const QPixmap &icon);
|
void startDrag(QMimeData *mimeData, const QPixmap &icon);
|
||||||
void endDrag();
|
void endDrag();
|
||||||
|
@@ -1863,21 +1863,17 @@ bool Model::hasImport(const QString &importUrl) const
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Model::generateNewId(const QString &prefixName, const QString &fallbackPrefix,
|
QString Model::generateNewId(const QString &prefixName, const QString &fallbackPrefix) const
|
||||||
std::optional<std::function<bool(const QString &)>> isDuplicate) const
|
|
||||||
{
|
{
|
||||||
QString newId = prefixName;
|
QString newId = prefixName;
|
||||||
|
|
||||||
if (newId.isEmpty())
|
if (newId.isEmpty())
|
||||||
newId = fallbackPrefix;
|
newId = fallbackPrefix;
|
||||||
|
|
||||||
if (!isDuplicate.has_value()) // TODO: to be removed separately to not break build
|
|
||||||
isDuplicate = std::bind(&Model::hasId, this, std::placeholders::_1);
|
|
||||||
|
|
||||||
return UniqueName::generateId(prefixName, [&] (const QString &id) {
|
return UniqueName::generateId(prefixName, [&] (const QString &id) {
|
||||||
// Properties of the root node are not allowed for ids, because they are available in the
|
// Properties of the root node are not allowed for ids, because they are available in the
|
||||||
// complete context without qualification.
|
// complete context without qualification.
|
||||||
return isDuplicate.value()(id) || d->rootNode()->property(id.toUtf8());
|
return hasId(id) || d->rootNode()->property(id.toUtf8());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user