Commit c8bb611f authored by Tim Jenssen's avatar Tim Jenssen

QmlDesigner: trigger item library update after MetaInforReader is finished

 - this speeds up the start of the QmlDesigner

Change-Id: I0fd5804f3aad799a93fd2c47edca8d1ca5c3c454
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@theqtcompany.com>
parent cfed8095
......@@ -100,7 +100,7 @@ public:
QList<ItemLibraryEntry> entriesForType(const QByteArray &typeName, int majorVersion, int minorVersion) const;
ItemLibraryEntry entry(const QString &name) const;
void addEntry(const ItemLibraryEntry &entry, bool overwriteDuplicate = false);
void addEntries(const QList<ItemLibraryEntry> &entries, bool overwriteDuplicate = false);
bool containsEntry(const ItemLibraryEntry &entry);
void clearEntries();
......
......@@ -89,7 +89,8 @@ private:
ParserSate parserState() const;
void setParserState(ParserSate newParserState);
void insertItemLibraryEntry();
void syncItemLibraryEntries();
void keepCurrentItemLibraryEntry();
void insertProperty();
void addErrorInvalidType(const QString &typeName);
......@@ -104,6 +105,7 @@ private:
QString m_currentIcon;
QString m_currentSource;
ItemLibraryEntry m_currentEntry;
QList<ItemLibraryEntry> m_bufferedEntries;
PropertyName m_currentPropertyName;
QString m_currentPropertyType;
......
......@@ -300,13 +300,14 @@ static inline QString keyForEntry(const ItemLibraryEntry &entry)
return entry.name() + entry.category() + QString::number(entry.majorVersion());
}
void ItemLibraryInfo::addEntry(const ItemLibraryEntry &entry, bool overwriteDuplicate)
void ItemLibraryInfo::addEntries(const QList<ItemLibraryEntry> &entries, bool overwriteDuplicate)
{
const QString key = keyForEntry(entry);
if (!overwriteDuplicate && m_nameToEntryHash.contains(key))
throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__);
m_nameToEntryHash.insert(key, entry);
foreach (const ItemLibraryEntry &entry, entries) {
const QString key = keyForEntry(entry);
if (!overwriteDuplicate && m_nameToEntryHash.contains(key))
throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__);
m_nameToEntryHash.insert(key, entry);
}
emit entriesChanged();
}
......
......@@ -69,6 +69,7 @@ void MetaInfoReader::readMetaInfoFile(const QString &path, bool overwriteDuplica
m_parserState = Error;
throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__);
}
syncItemLibraryEntries();
}
QStringList MetaInfoReader::errors()
......@@ -103,7 +104,7 @@ void MetaInfoReader::elementEnd()
switch (parserState()) {
case ParsingMetaInfo: setParserState(Finished); break;
case ParsingType: setParserState(ParsingMetaInfo); break;
case ParsingItemLibrary: insertItemLibraryEntry(); setParserState((ParsingType)); break;
case ParsingItemLibrary: keepCurrentItemLibraryEntry(); setParserState((ParsingType)); break;
case ParsingProperty: insertProperty(); setParserState(ParsingItemLibrary); break;
case ParsingQmlSource: setParserState(ParsingItemLibrary); break;
case ParsingDocument:
......@@ -281,24 +282,22 @@ MetaInfoReader::ParserSate MetaInfoReader::parserState() const
void MetaInfoReader::setParserState(ParserSate newParserState)
{
if (debug && newParserState == Error)
qDebug() << "Error";
m_parserState = newParserState;
}
void MetaInfoReader::insertItemLibraryEntry()
void MetaInfoReader::syncItemLibraryEntries()
{
if (debug) {
qDebug() << "insertItemLibraryEntry()";
qDebug() << m_currentEntry;
}
try {
m_metaInfo.itemLibraryInfo()->addEntry(m_currentEntry, m_overwriteDuplicates);
m_metaInfo.itemLibraryInfo()->addEntries(m_bufferedEntries, m_overwriteDuplicates);
} catch (const InvalidMetaInfoException &) {
addError(tr("Invalid or duplicate item library entry %1").arg(m_currentEntry.name()), currentSourceLocation());
}
m_bufferedEntries.clear();
}
void MetaInfoReader::keepCurrentItemLibraryEntry()
{
m_bufferedEntries.append(m_currentEntry);
}
void MetaInfoReader::insertProperty()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment