Skip to content

Commit

Permalink
addImportPath etc
Browse files Browse the repository at this point in the history
* addImportPath, importPathList functions for engine.
* Qt.createComponent uses importPathList for qml files lookup.
  • Loading branch information
pavelvasev committed Mar 2, 2015
1 parent 72b7834 commit 7475fce
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/qtcore.js
Expand Up @@ -174,8 +174,17 @@ Qt.createComponent = function(name, executionContext)
var file = engine.$basePath + name;

var src = getUrlContents(file);
if (src=="")
return undefined;
if (src=="") {
var moredirs = engine.importPathList();
for (var i=0; i<moredirs.length; i++) {
file = moredirs[i] + name;
src = getUrlContents(file);
if (src != "") break;
}
if (src == "")
return undefined;
}

var tree = parseQML(src);

if (tree.$children.length !== 1)
Expand Down Expand Up @@ -789,6 +798,14 @@ QMLEngine = function (element, options) {
return this.$basePath + file;
}

this.addImportPath = function( dirpath ) {
if (!this.userAddedLibraryPaths) this.userAddedImportPaths = [];
this.userAddedImportPaths.push( dirpath );
}
this.importPathList = function() {
return (this.userAddedImportPaths || []);
}

this.$registerStart = function(f)
{
whenStart.push(f);
Expand Down

0 comments on commit 7475fce

Please sign in to comment.