forked from qt-creator/qt-creator
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.
This commit is contained in:
@@ -433,7 +433,7 @@ Rectangle {
|
|||||||
// border
|
// border
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill:parent;
|
anchors.fill:parent;
|
||||||
color:"Transparent";
|
color:"#000000"
|
||||||
border.width:1;
|
border.width:1;
|
||||||
border.color:"#8F8F8F";
|
border.color:"#8F8F8F";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class QmlProjectItemPrivate : public QObject {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
QString sourceDirectory;
|
QString sourceDirectory;
|
||||||
|
QStringList libraryPaths;
|
||||||
|
|
||||||
QList<QmlFileFilterItem*> qmlFileFilters() const;
|
QList<QmlFileFilterItem*> qmlFileFilters() const;
|
||||||
|
|
||||||
@@ -78,6 +79,23 @@ void QmlProjectItem::setSourceDirectory(const QString &directoryPath)
|
|||||||
emit sourceDirectoryChanged();
|
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 */
|
/* Returns list of absolute paths */
|
||||||
QStringList QmlProjectItem::files() const
|
QStringList QmlProjectItem::files() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class QmlProjectItem : public QObject {
|
|||||||
|
|
||||||
Q_PROPERTY(QmlList<QmlProjectManager::QmlProjectContentItem*> *content READ content DESIGNABLE false)
|
Q_PROPERTY(QmlList<QmlProjectManager::QmlProjectContentItem*> *content READ content DESIGNABLE false)
|
||||||
Q_PROPERTY(QString sourceDirectory READ sourceDirectory NOTIFY sourceDirectoryChanged)
|
Q_PROPERTY(QString sourceDirectory READ sourceDirectory NOTIFY sourceDirectoryChanged)
|
||||||
|
Q_PROPERTY(QStringList libraryPaths READ libraryPaths WRITE setLibraryPaths NOTIFY libraryPathsChanged)
|
||||||
|
|
||||||
Q_CLASSINFO("DefaultProperty", "content");
|
Q_CLASSINFO("DefaultProperty", "content");
|
||||||
|
|
||||||
@@ -35,11 +36,15 @@ public:
|
|||||||
QString sourceDirectory() const;
|
QString sourceDirectory() const;
|
||||||
void setSourceDirectory(const QString &directoryPath);
|
void setSourceDirectory(const QString &directoryPath);
|
||||||
|
|
||||||
|
QStringList libraryPaths() const;
|
||||||
|
void setLibraryPaths(const QStringList &paths);
|
||||||
|
|
||||||
QStringList files() const;
|
QStringList files() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void qmlFilesChanged();
|
void qmlFilesChanged();
|
||||||
void sourceDirectoryChanged();
|
void sourceDirectoryChanged();
|
||||||
|
void libraryPathsChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QmlProjectItemPrivate *d_ptr;
|
QmlProjectItemPrivate *d_ptr;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void testFileFilter();
|
void testFileFilter();
|
||||||
|
void testLibraryPaths();
|
||||||
};
|
};
|
||||||
|
|
||||||
TestProject::TestProject()
|
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);
|
QTEST_MAIN(TestProject);
|
||||||
#include "tst_fileformat.moc"
|
#include "tst_fileformat.moc"
|
||||||
|
|||||||
Reference in New Issue
Block a user