From 28b512df4485edd5ed3d23c68e57dcc27dd9a270 Mon Sep 17 00:00:00 2001
From: Thomas Hartmann <Thomas.Hartmann@digia.com>
Date: Wed, 7 May 2014 13:00:57 +0200
Subject: [PATCH] QmlDesigner.ItemLibrary: remove forceEntry

This feature allowed items to show up in the library even if the import
was missing. This feature was error prone and increased the complexity
of creating items a lot. Since we now have an import manager this is not
required anymore.

Change-Id: Ia127077be0b6c82a047cbb8f86ac3ab24e2d82ae
Reviewed-by: Marco Bubke <marco.bubke@digia.com>
---
 .../components/itemlibrary/itemlibrarymodel.cpp    |  4 ++--
 .../designercore/include/itemlibraryinfo.h         |  3 +--
 .../designercore/metainfo/itemlibraryinfo.cpp      | 14 --------------
 .../designercore/metainfo/metainforeader.cpp       |  3 ---
 4 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp
index d1b507a170d..747a9dddfac 100644
--- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp
+++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp
@@ -508,9 +508,9 @@ void ItemLibraryModel::update(ItemLibraryInfo *itemLibraryInfo, Model *model)
          NodeMetaInfo metaInfo = model->metaInfo(entry.typeName(), -1, -1);
          bool valid = metaInfo.isValid() && metaInfo.majorVersion() == entry.majorVersion();
 
-         if ((valid || entry.forceImport())
+         if (valid
                  && (entry.requiredImport().isEmpty()
-                     || model->hasImport(entryToImport(entry), true, true) || entry.forceImport())) {
+                     || model->hasImport(entryToImport(entry), true, true))) {
             QString itemSectionName = entry.category();
             ItemLibrarySectionModel *sectionModel;
             ItemLibraryItemModel *itemModel;
diff --git a/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h b/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h
index 5916267a249..b6ab32b6041 100644
--- a/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h
+++ b/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h
@@ -72,7 +72,6 @@ public:
     QString qmlPath() const;
     QString qmlSource() const;
     QString requiredImport() const;
-    bool forceImport() const;
 
     ItemLibraryEntry(const ItemLibraryEntry &other);
     ItemLibraryEntry& operator=(const ItemLibraryEntry &other);
@@ -91,7 +90,7 @@ public:
     void setCategory(const QString &category);
     void setQmlPath(const QString &qml);
     void setRequiredImport(const QString &requiredImport);
-    void setForceImport(bool b);
+
 private:
     QExplicitlySharedDataPointer<Internal::ItemLibraryEntryData> m_data;
 };
diff --git a/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp
index 5ee176d41b1..c9e1189ade8 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp
@@ -55,7 +55,6 @@ public:
     QString qml;
     QString qmlSource;
     QString requiredImport;
-    bool forceImport;
 };
 
 } // namespace Internal
@@ -136,11 +135,6 @@ QString ItemLibraryEntry::requiredImport() const
     return m_data->requiredImport;
 }
 
-bool ItemLibraryEntry::forceImport() const
-{
-    return m_data->forceImport;
-}
-
 int ItemLibraryEntry::majorVersion() const
 {
     return m_data->majorVersion;
@@ -210,11 +204,6 @@ void ItemLibraryEntry::setRequiredImport(const QString &requiredImport)
     m_data->requiredImport = requiredImport;
 }
 
-void ItemLibraryEntry::setForceImport(bool b)
-{
-    m_data->forceImport = b;
-}
-
 void ItemLibraryEntry::addProperty(PropertyName &name, QString &type, QVariant &value)
 {
     Property property;
@@ -233,7 +222,6 @@ QDataStream& operator<<(QDataStream& stream, const ItemLibraryEntry &itemLibrary
     stream << itemLibraryEntry.category();
     stream << itemLibraryEntry.dragIcon();
     stream << itemLibraryEntry.requiredImport();
-    stream << itemLibraryEntry.forceImport();
 
     stream << itemLibraryEntry.m_data->properties;
     stream << itemLibraryEntry.m_data->qml;
@@ -253,7 +241,6 @@ QDataStream& operator>>(QDataStream& stream, ItemLibraryEntry &itemLibraryEntry)
     stream >> itemLibraryEntry.m_data->category;
     stream >> itemLibraryEntry.m_data->dragIcon;
     stream >> itemLibraryEntry.m_data->requiredImport;
-    stream >> itemLibraryEntry.m_data->forceImport;
 
     stream >> itemLibraryEntry.m_data->properties;
     stream >> itemLibraryEntry.m_data->qml;
@@ -273,7 +260,6 @@ QDebug operator<<(QDebug debug, const ItemLibraryEntry &itemLibraryEntry)
     debug << itemLibraryEntry.m_data->category;
     debug << itemLibraryEntry.m_data->dragIcon;
     debug << itemLibraryEntry.m_data->requiredImport;
-    debug << itemLibraryEntry.m_data->forceImport;
 
     debug << itemLibraryEntry.m_data->properties;
     debug << itemLibraryEntry.m_data->qml;
diff --git a/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp b/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp
index 8b4680bc74d..7b69a39ce8b 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp
@@ -164,7 +164,6 @@ MetaInfoReader::ParserSate MetaInfoReader::readTypeElement(const QString &name)
 {
     if (name == QLatin1String(ItemLibraryEntryElementName)) {
         m_currentEntry = ItemLibraryEntry();
-        m_currentEntry.setForceImport(false);
         m_currentEntry.setType(m_currentClassName, -1, -1);
         m_currentEntry.setIcon(QIcon(m_currentIcon));
         return ParsingItemLibrary;
@@ -227,8 +226,6 @@ void MetaInfoReader::readItemLibraryEntryProperty(const QString &name, const QVa
         setVersion(value.toString());
     } else if (name == QLatin1String("requiredImport")) {
         m_currentEntry.setRequiredImport(value.toString());
-    } else if (name == QLatin1String("forceImport")) {
-        m_currentEntry.setForceImport(value.toBool());
     } else {
         addError(tr("Unknown property for ItemLibraryEntry %1").arg(name), currentSourceLocation());
         setParserState(Error);
-- 
GitLab