forked from qt-creator/qt-creator
QmlDesigner: trigger item library update after MetaInforReader is finished
- this speeds up the start of the QmlDesigner Change-Id: I0fd5804f3aad799a93fd2c47edca8d1ca5c3c454 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
This commit is contained in:
@@ -100,7 +100,7 @@ public:
|
|||||||
QList<ItemLibraryEntry> entriesForType(const QByteArray &typeName, int majorVersion, int minorVersion) const;
|
QList<ItemLibraryEntry> entriesForType(const QByteArray &typeName, int majorVersion, int minorVersion) const;
|
||||||
ItemLibraryEntry entry(const QString &name) 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);
|
bool containsEntry(const ItemLibraryEntry &entry);
|
||||||
void clearEntries();
|
void clearEntries();
|
||||||
|
|
||||||
|
@@ -89,7 +89,8 @@ private:
|
|||||||
ParserSate parserState() const;
|
ParserSate parserState() const;
|
||||||
void setParserState(ParserSate newParserState);
|
void setParserState(ParserSate newParserState);
|
||||||
|
|
||||||
void insertItemLibraryEntry();
|
void syncItemLibraryEntries();
|
||||||
|
void keepCurrentItemLibraryEntry();
|
||||||
void insertProperty();
|
void insertProperty();
|
||||||
|
|
||||||
void addErrorInvalidType(const QString &typeName);
|
void addErrorInvalidType(const QString &typeName);
|
||||||
@@ -104,6 +105,7 @@ private:
|
|||||||
QString m_currentIcon;
|
QString m_currentIcon;
|
||||||
QString m_currentSource;
|
QString m_currentSource;
|
||||||
ItemLibraryEntry m_currentEntry;
|
ItemLibraryEntry m_currentEntry;
|
||||||
|
QList<ItemLibraryEntry> m_bufferedEntries;
|
||||||
|
|
||||||
PropertyName m_currentPropertyName;
|
PropertyName m_currentPropertyName;
|
||||||
QString m_currentPropertyType;
|
QString m_currentPropertyType;
|
||||||
|
@@ -300,13 +300,14 @@ static inline QString keyForEntry(const ItemLibraryEntry &entry)
|
|||||||
return entry.name() + entry.category() + QString::number(entry.majorVersion());
|
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);
|
foreach (const ItemLibraryEntry &entry, entries) {
|
||||||
if (!overwriteDuplicate && m_nameToEntryHash.contains(key))
|
const QString key = keyForEntry(entry);
|
||||||
throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__);
|
if (!overwriteDuplicate && m_nameToEntryHash.contains(key))
|
||||||
m_nameToEntryHash.insert(key, entry);
|
throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__);
|
||||||
|
m_nameToEntryHash.insert(key, entry);
|
||||||
|
}
|
||||||
emit entriesChanged();
|
emit entriesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,6 +69,7 @@ void MetaInfoReader::readMetaInfoFile(const QString &path, bool overwriteDuplica
|
|||||||
m_parserState = Error;
|
m_parserState = Error;
|
||||||
throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__);
|
throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__);
|
||||||
}
|
}
|
||||||
|
syncItemLibraryEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList MetaInfoReader::errors()
|
QStringList MetaInfoReader::errors()
|
||||||
@@ -103,7 +104,7 @@ void MetaInfoReader::elementEnd()
|
|||||||
switch (parserState()) {
|
switch (parserState()) {
|
||||||
case ParsingMetaInfo: setParserState(Finished); break;
|
case ParsingMetaInfo: setParserState(Finished); break;
|
||||||
case ParsingType: setParserState(ParsingMetaInfo); 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 ParsingProperty: insertProperty(); setParserState(ParsingItemLibrary); break;
|
||||||
case ParsingQmlSource: setParserState(ParsingItemLibrary); break;
|
case ParsingQmlSource: setParserState(ParsingItemLibrary); break;
|
||||||
case ParsingDocument:
|
case ParsingDocument:
|
||||||
@@ -281,24 +282,22 @@ MetaInfoReader::ParserSate MetaInfoReader::parserState() const
|
|||||||
|
|
||||||
void MetaInfoReader::setParserState(ParserSate newParserState)
|
void MetaInfoReader::setParserState(ParserSate newParserState)
|
||||||
{
|
{
|
||||||
if (debug && newParserState == Error)
|
|
||||||
qDebug() << "Error";
|
|
||||||
|
|
||||||
m_parserState = newParserState;
|
m_parserState = newParserState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaInfoReader::insertItemLibraryEntry()
|
void MetaInfoReader::syncItemLibraryEntries()
|
||||||
{
|
{
|
||||||
if (debug) {
|
|
||||||
qDebug() << "insertItemLibraryEntry()";
|
|
||||||
qDebug() << m_currentEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m_metaInfo.itemLibraryInfo()->addEntry(m_currentEntry, m_overwriteDuplicates);
|
m_metaInfo.itemLibraryInfo()->addEntries(m_bufferedEntries, m_overwriteDuplicates);
|
||||||
} catch (const InvalidMetaInfoException &) {
|
} catch (const InvalidMetaInfoException &) {
|
||||||
addError(tr("Invalid or duplicate item library entry %1").arg(m_currentEntry.name()), currentSourceLocation());
|
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()
|
void MetaInfoReader::insertProperty()
|
||||||
|
Reference in New Issue
Block a user