Commit 85773474 authored by Kai Koehne's avatar Kai Koehne
Browse files

Add libraryPaths array to Project element (.qmlproject format)

Will be passed to qmlviewer with the "-L" option. Storing this in
the .qmlproject file format itself (and not in the .user file) is useful
in case the libraries are relative/part of the checkout that is shared
between users/computers.
parent fbee8695
......@@ -433,7 +433,7 @@ Rectangle {
// border
Rectangle {
anchors.fill:parent;
color:"Transparent";
color:"#000000"
border.width:1;
border.color:"#8F8F8F";
}
......
......@@ -9,6 +9,7 @@ class QmlProjectItemPrivate : public QObject {
public:
QString sourceDirectory;
QStringList libraryPaths;
QList<QmlFileFilterItem*> qmlFileFilters() const;
......@@ -78,6 +79,23 @@ void QmlProjectItem::setSourceDirectory(const QString &directoryPath)
emit sourceDirectoryChanged();
}
QStringList QmlProjectItem::libraryPaths() const
{
const Q_D(QmlProjectItem);
return d->libraryPaths;
}
void QmlProjectItem::setLibraryPaths(const QStringList &libraryPaths)
{
Q_D(QmlProjectItem);
if (d->libraryPaths == libraryPaths)
return;
d->libraryPaths = libraryPaths;
emit libraryPathsChanged();
}
/* Returns list of absolute paths */
QStringList QmlProjectItem::files() const
{
......
......@@ -23,6 +23,7 @@ class QmlProjectItem : public QObject {
Q_PROPERTY(QmlList<QmlProjectManager::QmlProjectContentItem*> *content READ content DESIGNABLE false)
Q_PROPERTY(QString sourceDirectory READ sourceDirectory NOTIFY sourceDirectoryChanged)
Q_PROPERTY(QStringList libraryPaths READ libraryPaths WRITE setLibraryPaths NOTIFY libraryPathsChanged)
Q_CLASSINFO("DefaultProperty", "content");
......@@ -35,11 +36,15 @@ public:
QString sourceDirectory() const;
void setSourceDirectory(const QString &directoryPath);
QStringList libraryPaths() const;
void setLibraryPaths(const QStringList &paths);
QStringList files() const;
signals:
void qmlFilesChanged();
void sourceDirectoryChanged();
void libraryPathsChanged();
protected:
QmlProjectItemPrivate *d_ptr;
......
......@@ -15,6 +15,7 @@ public:
private slots:
void testFileFilter();
void testLibraryPaths();
};
TestProject::TestProject()
......@@ -204,6 +205,36 @@ void TestProject::testFileFilter()
}
}
void TestProject::testLibraryPaths()
{
//
// search for qml files in local directory
//
QString projectFile = QLatin1String(
"import QmlProject 1.0\n"
"Project {\n"
" libraryPaths: [ \"../otherLibrary\", \"library\" ]\n"
"}\n");
{
QmlEngine engine;
QmlComponent component(&engine);
component.setData(projectFile.toUtf8(), QUrl());
if (!component.isReady())
qDebug() << component.errorsString();
QVERIFY(component.isReady());
QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
QVERIFY(project);
project->setSourceDirectory(testDataDir);
QStringList expectedPaths(QStringList() << "../otherLibrary"
<< "library");
QCOMPARE(project->libraryPaths().toSet(), expectedPaths.toSet());
}
}
QTEST_MAIN(TestProject);
#include "tst_fileformat.moc"
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