diff options
author | Leon Bottou <leon@bottou.org> | 2013-04-12 03:48:17 +0400 |
---|---|---|
committer | Leon Bottou <leon@bottou.org> | 2013-08-11 00:18:42 +0400 |
commit | 1d74f5e0f21c69e50c0404904c151976beb0bb76 (patch) | |
tree | 0a88ccad92af43f27a8025c145b576f0b7865c0f | |
parent | b8d124c2e7c445ecbda4f5322f8c68ebe2c04560 (diff) |
qurl local file funcs (and qtide fix)
-rw-r--r-- | packages/qtcore/dok/index.dok | 12 | ||||
-rw-r--r-- | packages/qtcore/qtcore.cpp | 21 | ||||
-rw-r--r-- | packages/qtide/init.lua | 4 |
3 files changed, 35 insertions, 2 deletions
diff --git a/packages/qtcore/dok/index.dok b/packages/qtcore/dok/index.dok index 1d9224b..88ef9db 100644 --- a/packages/qtcore/dok/index.dok +++ b/packages/qtcore/dok/index.dok @@ -346,6 +346,18 @@ QUrl object from string ''string''. Expression ''qurl:tostring()'' returns a string describing the QUrl object ''qurl''. +==== qurl.fromlocalfile(s) === + +Returns a file url associated with the file named s. + +==== qurl:tolocalfile() === +{{anchor:qurl.tolocalfile}} + +If the url describes a local file, +expression ''qurl:tolocalfile()'' returns a string +describing the local filename associated with the url. +Otherwise it returns nil. + ===== qt.QVariantList ===== {{anchor:qvariantlist}} diff --git a/packages/qtcore/qtcore.cpp b/packages/qtcore/qtcore.cpp index fe7676a..e995af5 100644 --- a/packages/qtcore/qtcore.cpp +++ b/packages/qtcore/qtcore.cpp @@ -543,10 +543,31 @@ qurl_new(lua_State *L) return 1; } +static int +qurl_tolocalfile(lua_State *L) +{ + QUrl url = luaQ_checkqvariant<QUrl>(L, 1); + if (url.isLocalFile()) + lua_pushstring(L, url.toLocalFile().toLocal8Bit().constData()); + else + lua_pushnil(L); + return 1; +} + +static int +qurl_fromlocalfile(lua_State *L) +{ + QString s = luaQ_checkqvariant<QString>(L, 1); + luaQ_pushqt(L, QUrl::fromLocalFile(s)); + return 1; +} + static const luaL_Reg qurl_lib[] = { {"tostring", qurl_tostring}, {"new", qurl_new}, + {"tolocalfile", qurl_tolocalfile}, + {"fromlocalfile", qurl_fromlocalfile}, {0, 0} }; diff --git a/packages/qtide/init.lua b/packages/qtide/init.lua index 5c69207..524503f 100644 --- a/packages/qtide/init.lua +++ b/packages/qtide/init.lua @@ -149,9 +149,9 @@ local function locate_help_files() local index1 = paths.concat(paths.install_html, appname:lower(), "index.html") local index2 = paths.concat(paths.install_html,"index.html") if index1 and paths.filep(index1) then - return qt.QUrl(index1) + return qt.QUrl.fromlocalfile(index1) elseif index2 and paths.filep(index2) then - return qt.QUrl(index2) + return qt.QUrl.fromlocalfile(index2) else return qt.QUrl("http://torch5.sourceforge.net/manual/index.html") end |