Commit f9e675bf authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.SubComponentManager: support for .metainfo files



Instead of scanning the directory for components we first look
for .metainfo files and populate the item library from them.

If we find a .metainfo file we do not scan manually anymore.

Change-Id: I07985860bb387a3f9e48f4bf9b0fa2a413d8e055
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent f8b6a8a5
......@@ -27,14 +27,18 @@
**
****************************************************************************/
#include <qmldesignerconstants.h>
#include "subcomponentmanager.h"
#include "model.h"
#include "metainfo.h"
#include "metainforeader.h"
#include <utils/hostosinfo.h>
#include <QDir>
#include <QMetaType>
#include <QMessageBox>
#include <QUrl>
enum { debug = false };
......@@ -164,6 +168,33 @@ void SubComponentManager::parseDirectories()
void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool addToLibrary, const QString& qualification)
{
QDir designerDir(canonicalDirPath + Constants::QML_DESIGNER_SUBFOLDER);
if (designerDir.exists()) {
QStringList filter;
filter << "*.metainfo";
designerDir.setNameFilters(filter);
QStringList metaFiles = designerDir.entryList(QDir::Files);
foreach (const QFileInfo &metaInfoFile, designerDir.entryInfoList(QDir::Files)) {
if (model() && model()->metaInfo().itemLibraryInfo()) {
Internal::MetaInfoReader reader(model()->metaInfo());
try {
reader.readMetaInfoFile(metaInfoFile.absoluteFilePath(), true);
} catch (InvalidMetaInfoException &e) {
qWarning() << e.description();
const QString errorMessage = metaInfoFile.absoluteFilePath() + QLatin1Char('\n') + QLatin1Char('\n') + reader.errors().join(QLatin1String("\n"));
QMessageBox::critical(0,
QCoreApplication::translate("SubComponentManager::parseDirectory", "Invalid meta info"),
errorMessage);
}
}
}
if (!metaFiles.isEmpty()) {
return;
}
}
if (debug)
qDebug() << Q_FUNC_INFO << canonicalDirPath;
......
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