forked from qt-creator/qt-creator
QmlDesigner: Fix import removal issues
Fixes the issue of removing all versions of import when one is removed via item library. Also fixes a bug in item library that allowed removal of used imports in some situations, such as directly after another import was removed. Change-Id: I0ad879c8be708873b716fe6326655bcbc66a566a Fixes: QDS-1989 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -81,8 +81,12 @@ void ImportManagerView::modelAboutToBeDetached(Model *model)
|
|||||||
|
|
||||||
void ImportManagerView::importsChanged(const QList<Import> &/*addedImports*/, const QList<Import> &/*removedImports*/)
|
void ImportManagerView::importsChanged(const QList<Import> &/*addedImports*/, const QList<Import> &/*removedImports*/)
|
||||||
{
|
{
|
||||||
if (m_importsWidget)
|
if (m_importsWidget) {
|
||||||
m_importsWidget->setImports(model()->imports());
|
m_importsWidget->setImports(model()->imports());
|
||||||
|
// setImports recreates labels, so we need to update used imports, as it is not guaranteed
|
||||||
|
// usedImportsChanged notification will come after this.
|
||||||
|
m_importsWidget->setUsedImports(model()->usedImports());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportManagerView::possibleImportsChanged(const QList<Import> &/*possibleImports*/)
|
void ImportManagerView::possibleImportsChanged(const QList<Import> &/*possibleImports*/)
|
||||||
|
@@ -85,10 +85,25 @@ bool ChangeImportsVisitor::remove(QmlJS::AST::UiProgram *ast, const Import &impo
|
|||||||
|
|
||||||
bool ChangeImportsVisitor::equals(QmlJS::AST::UiImport *ast, const Import &import)
|
bool ChangeImportsVisitor::equals(QmlJS::AST::UiImport *ast, const Import &import)
|
||||||
{
|
{
|
||||||
|
bool equal = false;
|
||||||
if (import.isLibraryImport())
|
if (import.isLibraryImport())
|
||||||
return toString(ast->importUri) == import.url();
|
equal = toString(ast->importUri) == import.url();
|
||||||
else if (import.isFileImport())
|
else if (import.isFileImport())
|
||||||
return ast->fileName == import.file();
|
equal = ast->fileName == import.file();
|
||||||
else
|
|
||||||
return false;
|
if (equal) {
|
||||||
|
equal = (!ast->version || (ast->version->minorVersion == 0 && ast->version->majorVersion == 0))
|
||||||
|
&& import.version().isEmpty();
|
||||||
|
if (!equal && ast->version) {
|
||||||
|
const QStringList versions = import.version().split('.');
|
||||||
|
if (versions.size() >= 1 && versions[0].toInt() == ast->version->majorVersion) {
|
||||||
|
if (versions.size() >= 2)
|
||||||
|
equal = versions[1].toInt() == ast->version->minorVersion;
|
||||||
|
else
|
||||||
|
equal = ast->version->minorVersion == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return equal;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user