forked from qt-creator/qt-creator
QmlProject: Implement basic support for QmlFileSelector
This patch adds support for QmlFileSelector for QmlProject and Qt Quick Designer. Task-number: QDS-590 Change-Id: I0cc043d3ec9578008ec879b36fe834b70fb8c5ad Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -88,6 +88,10 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FileName &fi
|
||||
if (importPathsProperty.isValid())
|
||||
projectItem->setImportPaths(importPathsProperty.toStringList());
|
||||
|
||||
const QVariant fileSelectorsProperty = rootNode->property(QLatin1String("fileSelectors"));
|
||||
if (fileSelectorsProperty.isValid())
|
||||
projectItem->setFileSelectors(fileSelectorsProperty.toStringList());
|
||||
|
||||
const QVariant targetDirectoryPropery = rootNode->property("targetDirectory");
|
||||
if (targetDirectoryPropery.isValid())
|
||||
projectItem->setTargetDirectory(targetDirectoryPropery.toString());
|
||||
|
||||
@@ -59,6 +59,12 @@ void QmlProjectItem::setImportPaths(const QStringList &importPaths)
|
||||
m_importPaths = importPaths;
|
||||
}
|
||||
|
||||
void QmlProjectItem::setFileSelectors(const QStringList &selectors)
|
||||
{
|
||||
if (m_fileSelectors != selectors)
|
||||
m_fileSelectors = selectors;
|
||||
}
|
||||
|
||||
/* Returns list of absolute paths */
|
||||
QStringList QmlProjectItem::files() const
|
||||
{
|
||||
|
||||
@@ -54,6 +54,9 @@ public:
|
||||
QStringList importPaths() const { return m_importPaths; }
|
||||
void setImportPaths(const QStringList &paths);
|
||||
|
||||
QStringList fileSelectors() const { return m_fileSelectors; }
|
||||
void setFileSelectors(const QStringList &selectors);
|
||||
|
||||
QStringList files() const;
|
||||
bool matchesFile(const QString &filePath) const;
|
||||
|
||||
@@ -72,6 +75,7 @@ protected:
|
||||
QString m_sourceDirectory;
|
||||
QString m_targetDirectory;
|
||||
QStringList m_importPaths;
|
||||
QStringList m_fileSelectors;
|
||||
QString m_mainFile;
|
||||
QList<Utils::EnvironmentItem> m_environment;
|
||||
QList<QmlProjectContentItem *> m_content; // content property
|
||||
|
||||
@@ -225,6 +225,13 @@ QStringList QmlProject::customImportPaths() const
|
||||
return {};
|
||||
}
|
||||
|
||||
QStringList QmlProject::customFileSelectors() const
|
||||
{
|
||||
if (m_projectItem)
|
||||
return m_projectItem.data()->fileSelectors();
|
||||
return {};
|
||||
}
|
||||
|
||||
bool QmlProject::addFiles(const QStringList &filePaths)
|
||||
{
|
||||
QStringList toAdd;
|
||||
@@ -256,6 +263,13 @@ QStringList QmlProject::makeAbsolute(const Utils::FileName &path, const QStringL
|
||||
});
|
||||
}
|
||||
|
||||
QVariant QmlProject::additionalData(Id id, const Target *) const
|
||||
{
|
||||
if (id == Constants::customFileSelectorsData)
|
||||
return customFileSelectors();
|
||||
return {};
|
||||
}
|
||||
|
||||
void QmlProject::refreshFiles(const QSet<QString> &/*added*/, const QSet<QString> &removed)
|
||||
{
|
||||
refresh(Files);
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
|
||||
QList<Utils::EnvironmentItem> environment() const;
|
||||
QStringList customImportPaths() const;
|
||||
QStringList customFileSelectors() const;
|
||||
|
||||
bool addFiles(const QStringList &filePaths);
|
||||
|
||||
@@ -79,6 +80,9 @@ public:
|
||||
bool needsBuildConfigurations() const final;
|
||||
|
||||
static QStringList makeAbsolute(const Utils::FileName &path, const QStringList &relativePaths);
|
||||
|
||||
QVariant additionalData(Core::Id id, const ProjectExplorer::Target *target) const override;
|
||||
|
||||
protected:
|
||||
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace QmlProjectManager {
|
||||
namespace Constants {
|
||||
|
||||
const char * const QMLPROJECT_MIMETYPE = QmlJSTools::Constants::QMLPROJECT_MIMETYPE;
|
||||
const char customFileSelectorsData[] = "CustomFileSelectorsData";
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -388,6 +388,11 @@ QString QmlProjectRunConfiguration::commandLineArguments() const
|
||||
Utils::QtcProcess::addArg(&args, importPath, osType);
|
||||
}
|
||||
|
||||
for (const QString &fileSelector : project->customFileSelectors()) {
|
||||
Utils::QtcProcess::addArg(&args, QLatin1String("-S"), osType);
|
||||
Utils::QtcProcess::addArg(&args, fileSelector, osType);
|
||||
}
|
||||
|
||||
const QString main = project->targetFile(Utils::FileName::fromString(mainScript()),
|
||||
currentTarget).toString();
|
||||
if (!main.isEmpty())
|
||||
|
||||
Reference in New Issue
Block a user