QObject: Add inherits(), property(), setProperty().

parent de0de826
// This file is part of Qtah.
//
// Copyright 2015-2018 The Qtah Authors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "wrap_qobject.hpp"
namespace qtah {
namespace qobject {
bool inherits(const QObject& obj, const QString& className) {
return obj.inherits(className.toStdString().c_str());
}
QVariant property(const QObject& obj, const QString& propertyName) {
return obj.property(propertyName.toStdString().c_str());
}
void setProperty(QObject& obj, const QString& propertyName, const QVariant& value) {
obj.setProperty(propertyName.toStdString().c_str(), value);
}
} // namespace qobject
} // namespace qtah
#ifndef QTAH_WRAP_QOBJECT_HPP
#define QTAH_WRAP_QOBJECT_HPP
// This file is part of Qtah.
//
// Copyright 2015-2018 The Qtah Authors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QObject>
#include <QString>
#include <QVariant>
namespace qtah {
namespace qobject {
bool inherits(const QObject& obj, const QString& className);
QVariant property(const QObject& obj, const QString& propertyName);
void setProperty(QObject& obj, const QString& propertyName, const QVariant& value);
} // namespace qobject
} // namespace qtah
#endif // QTAH_WRAP_QOBJECT_HPP
......@@ -22,24 +22,33 @@ module Graphics.UI.Qtah.Generator.Interface.Core.QObject (
import Foreign.Hoppy.Generator.Spec (
Export (ExportClass),
MethodApplicability (MConst, MNormal),
Purity (Nonpure),
addReqIncludes,
classSetEntityPrefix,
ident,
ident2,
includeLocal,
includeStd,
makeClass,
makeFnMethod,
mkConstMethod,
mkCtor,
mkMethod,
mkProp,
)
import Foreign.Hoppy.Generator.Types (boolT, intT, objT, ptrT, voidT)
import Foreign.Hoppy.Generator.Types (boolT, intT, objT, ptrT, refT, voidT)
import Foreign.Hoppy.Generator.Version (collect, just, test)
import Graphics.UI.Qtah.Generator.Flags (qtVersion)
import {-# SOURCE #-} Graphics.UI.Qtah.Generator.Interface.Internal.Listener
(c_ListenerPtrQObject, c_ListenerQString)
import {-# SOURCE #-} Graphics.UI.Qtah.Generator.Interface.Core.QList (c_QListQObject)
import {-# SOURCE #-} Graphics.UI.Qtah.Generator.Interface.Core.QList (
c_QListQByteArray,
c_QListQObject,
)
import Graphics.UI.Qtah.Generator.Interface.Core.QEvent (c_QEvent)
import Graphics.UI.Qtah.Generator.Interface.Core.QString (c_QString)
import {-# SOURCE #-} Graphics.UI.Qtah.Generator.Interface.Core.QVariant (c_QVariant)
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModule)
import Graphics.UI.Qtah.Generator.Types
......@@ -52,7 +61,9 @@ aModule =
] ++ map QtExportSignal signals
c_QObject =
addReqIncludes [includeStd "QObject"] $
addReqIncludes [ includeStd "QObject"
, includeLocal "wrap_qobject.hpp"
] $
classSetEntityPrefix "" $
makeClass (ident "QObject") Nothing [] $
collect
......@@ -65,12 +76,13 @@ c_QObject =
-- TODO disconnect
, just $ mkMethod "dumpObjectInfo" [] voidT
, just $ mkMethod "dumpObjectTree" [] voidT
-- TODO dynamicPropertyNames (>=4.2)
, just $ mkConstMethod "dynamicPropertyNames" [] $ objT c_QListQByteArray
, just $ mkMethod "event" [ptrT $ objT c_QEvent] boolT
, just $ mkMethod "eventFilter" [ptrT $ objT c_QObject, ptrT $ objT c_QEvent] boolT
-- TODO findChild
-- TODO findChildren
-- TODO inherits
, just $ makeFnMethod (ident2 "qtah" "qobject" "inherits") "inherits" MConst Nonpure
[objT c_QString] boolT
, just $ mkMethod "installEventFilter" [ptrT $ objT c_QObject] voidT
, just $ mkConstMethod "isWidgetType" [] boolT
, -- This is a guess on the version bound.
......@@ -80,9 +92,11 @@ c_QObject =
-- TODO moveToThread
, just $ mkProp "objectName" $ objT c_QString
, just $ mkProp "parent" $ ptrT $ objT c_QObject
-- TODO property
, just $ makeFnMethod (ident2 "qtah" "qobject" "property") "property" MConst Nonpure
[objT c_QObject, objT c_QString] $ objT c_QVariant
, just $ mkMethod "removeEventFilter" [ptrT $ objT c_QObject] voidT
-- TODO setProperty
, just $ makeFnMethod (ident2 "qtah" "qobject" "setProperty") "setProperty" MNormal Nonpure
[refT $ objT c_QObject, objT c_QString, objT c_QVariant] voidT
, just $ mkConstMethod "signalsBlocked" [] boolT
, just $ mkMethod "startTimer" [intT] intT
-- TODO thread
......
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