mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-11-05 05:26:55 +01:00
directoyListFiles generates now a table
This commit is contained in:
parent
6a1e98994c
commit
98f65a669f
2 changed files with 13 additions and 1 deletions
|
@ -210,6 +210,18 @@ void LuaEngine::pushVariant(lua_State *L_p, const QVariant &variant)
|
||||||
else if (variant.type() == QVariant::String) {
|
else if (variant.type() == QVariant::String) {
|
||||||
lua_pushstring(L_p, variant.toString().toUtf8().data());
|
lua_pushstring(L_p, variant.toString().toUtf8().data());
|
||||||
}
|
}
|
||||||
|
else if (variant.type() == QVariant::StringList) {
|
||||||
|
QStringList stringList = variant.toStringList();
|
||||||
|
lua_createtable(L_p, 0, stringList.count());
|
||||||
|
int top = lua_gettop(L_p);
|
||||||
|
int currentId = 1;
|
||||||
|
for (const QString &string : stringList) {
|
||||||
|
lua_pushnumber(L_p, currentId);
|
||||||
|
lua_pushstring(L_p, string.toUtf8().data());
|
||||||
|
lua_settable(L_p, top);
|
||||||
|
currentId++;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ((QMetaType::Type)variant.type() == QMetaType::Void || (QMetaType::Type)variant.type() == QMetaType::VoidStar) {
|
else if ((QMetaType::Type)variant.type() == QMetaType::Void || (QMetaType::Type)variant.type() == QMetaType::VoidStar) {
|
||||||
lua_pushlightuserdata(L_p, variant.value<void*>());
|
lua_pushlightuserdata(L_p, variant.value<void*>());
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ int LuaEngineOS::directoryListFiles(lua_State *L_p)
|
||||||
while (dirIterator.hasNext()) {
|
while (dirIterator.hasNext()) {
|
||||||
directories << dirIterator.next();
|
directories << dirIterator.next();
|
||||||
}
|
}
|
||||||
pushVariant(L_p, directories.join('\n'));
|
pushVariant(L_p, directories);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue