Add QAbstractItemView and friends.

parent 0a736394
......@@ -61,11 +61,15 @@ executable qtah-generator
, Graphics.UI.Qtah.Generator.Interface.Core.QCoreApplication
, Graphics.UI.Qtah.Generator.Interface.Core.QDir
, Graphics.UI.Qtah.Generator.Interface.Core.QEvent
, Graphics.UI.Qtah.Generator.Interface.Core.QItemSelection
, Graphics.UI.Qtah.Generator.Interface.Core.QItemSelectionModel
, Graphics.UI.Qtah.Generator.Interface.Core.QItemSelectionRange
, Graphics.UI.Qtah.Generator.Interface.Core.QList
, Graphics.UI.Qtah.Generator.Interface.Core.QMargins
, Graphics.UI.Qtah.Generator.Interface.Core.QMarginsF
, Graphics.UI.Qtah.Generator.Interface.Core.QModelIndex
, Graphics.UI.Qtah.Generator.Interface.Core.QObject
, Graphics.UI.Qtah.Generator.Interface.Core.QPersistentModelIndex
, Graphics.UI.Qtah.Generator.Interface.Core.QPoint
, Graphics.UI.Qtah.Generator.Interface.Core.QPointF
, Graphics.UI.Qtah.Generator.Interface.Core.QRect
......@@ -122,6 +126,7 @@ executable qtah-generator
, Graphics.UI.Qtah.Generator.Interface.Widgets
, Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractButton
, Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractGraphicsShapeItem
, Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractItemView
, Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractScrollArea
, Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractSlider
, Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractSpinBox
......
......@@ -76,14 +76,18 @@ forEachListener() {
$fn IntInt "int|int"
$fn PtrQAbstractButton "QAbstractButton*"
$fn PtrQAbstractButtonBool "QAbstractButton*|bool"
$fn PtrQAbstractItemModel "QAbstractItemModel*"
$fn PtrQAction "QAction*"
$fn PtrQObject "QObject*"
$fn PtrQWidgetPtrQWidget "QWidget*|QWidget*"
$fn RefConstQItemSelectionRefConstQItemSelection "const QItemSelection&|const QItemSelection&"
$fn ScreenOrientation "Qt::ScreenOrientation" 0x050000 '[5, 0]'
$fn QAbstractSliderAction "QAbstractSlider::SliderAction"
$fn QClipboardMode "QClipboard::Mode"
$fn QModelIndex "QModelIndex"
$fn QModelIndexIntInt "QModelIndex|int|int"
$fn QModelIndexIntIntQModelIndexInt "QModelIndex|int|int|QModelIndex|int"
$fn QModelIndexQModelIndex "QModelIndex|QModelIndex"
$fn QModelIndexQModelIndexQVectorInt "QModelIndex|QModelIndex|QVector<int>"
$fn QPoint "QPoint"
$fn Qreal "qreal"
......
......@@ -25,11 +25,15 @@ import qualified Graphics.UI.Qtah.Generator.Interface.Core.QChildEvent as QChild
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QCoreApplication as QCoreApplication
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QDir as QDir
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QEvent as QEvent
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QItemSelection as QItemSelection
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QItemSelectionModel as QItemSelectionModel
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QItemSelectionRange as QItemSelectionRange
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QList as QList
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QMargins as QMargins
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QMarginsF as QMarginsF
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QModelIndex as QModelIndex
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QObject as QObject
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QPersistentModelIndex as QPersistentModelIndex
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QPoint as QPoint
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QPointF as QPointF
import qualified Graphics.UI.Qtah.Generator.Interface.Core.QRect as QRect
......@@ -59,10 +63,14 @@ modules =
, QCoreApplication.aModule
, QDir.aModule
, QEvent.aModule
, QItemSelection.aModule
, QItemSelectionModel.aModule
, QItemSelectionRange.aModule
, QMargins.aModule
, QMarginsF.aModule
, QModelIndex.aModule
, QObject.aModule
, QPersistentModelIndex.aModule
, QPoint.aModule
, QPointF.aModule
, QRect.aModule
......
......@@ -53,7 +53,7 @@ import Graphics.UI.Qtah.Generator.Interface.Core.Types (
e_Orientation,
e_SortOrder,
)
import Graphics.UI.Qtah.Generator.Interface.Internal.Listener (
import {-# SOURCE #-} Graphics.UI.Qtah.Generator.Interface.Internal.Listener (
c_Listener,
c_ListenerQModelIndexIntInt,
c_ListenerQModelIndexIntIntQModelIndexInt,
......
-- This file is part of Qtah.
--
-- Copyright 2017 Bryan Gardiner <bog@khumba.net>
--
-- 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/>.
module Graphics.UI.Qtah.Generator.Interface.Core.QItemSelection (
aModule,
c_QItemSelection,
) where
import Foreign.Hoppy.Generator.Language.Haskell (
HsTypeSide (HsHsSide),
addImports,
cppTypeToHsTypeAndUse,
sayLn,
)
import Foreign.Hoppy.Generator.Spec (
ClassHaskellConversion (
ClassHaskellConversion,
classHaskellConversionFromCppFn,
classHaskellConversionToCppFn,
classHaskellConversionType
),
Export (ExportClass),
addAddendumHaskell,
addReqIncludes,
classSetEntityPrefix,
classSetHaskellConversion,
ident,
includeStd,
makeClass,
mkConstMethod,
mkCtor,
mkMethod,
mkStaticMethod,
)
import Foreign.Hoppy.Generator.Types (bitspaceT, boolT, objT, ptrT, voidT)
import {-# SOURCE #-} Graphics.UI.Qtah.Generator.Interface.Core.QItemSelectionModel (
bs_SelectionFlags,
)
import Graphics.UI.Qtah.Generator.Interface.Core.QItemSelectionRange (c_QItemSelectionRange)
import Graphics.UI.Qtah.Generator.Interface.Core.QList (
c_QListQItemSelectionRange,
c_QListQModelIndex,
inheritHasContents,
)
import Graphics.UI.Qtah.Generator.Interface.Core.QModelIndex (c_QModelIndex)
import Graphics.UI.Qtah.Generator.Interface.Imports (importForRuntime)
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModule)
import Graphics.UI.Qtah.Generator.Types
import Language.Haskell.Syntax (
HsQName (Special),
HsSpecialCon (HsListCon),
HsType (HsTyApp, HsTyCon),
)
{-# ANN module "HLint: ignore Use camelCase" #-}
aModule =
AQtModule $
makeQtModule ["Core", "QItemSelection"]
[ QtExport $ ExportClass c_QItemSelection ]
c_QItemSelection =
addReqIncludes [includeStd "QItemSelection"] $
-- This conversion mirrors QList but doesn't have a to-C++ conversion.
classSetHaskellConversion
ClassHaskellConversion
{ classHaskellConversionType = Just $ do
hsType <- cppTypeToHsTypeAndUse HsHsSide $ objT c_QItemSelectionRange
return $ HsTyApp (HsTyCon $ Special $ HsListCon) hsType
, classHaskellConversionToCppFn = Nothing
, classHaskellConversionFromCppFn = Just $ do
addImports importForRuntime
sayLn "QtahFHR.toContents"
} $
addAddendumHaskell
(inheritHasContents c_QItemSelection c_QListQItemSelectionRange $ objT c_QItemSelectionRange) $
classSetEntityPrefix "" $
makeClass (ident "QItemSelection") Nothing [c_QListQItemSelectionRange] $
[ mkCtor "new" []
, mkCtor "newWithRange" [objT c_QModelIndex, objT c_QModelIndex]
, mkConstMethod "contains" [objT c_QModelIndex] boolT
, mkConstMethod "indexes" [] $ objT c_QListQModelIndex
, mkMethod "merge" [objT c_QItemSelection, bitspaceT bs_SelectionFlags] voidT
, mkMethod "select" [objT c_QModelIndex, objT c_QModelIndex] voidT
, mkStaticMethod "split"
[objT c_QItemSelectionRange, objT c_QItemSelectionRange, ptrT $ objT c_QItemSelection] voidT
]
-- This file is part of Qtah.
--
-- Copyright 2017 Bryan Gardiner <bog@khumba.net>
--
-- 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/>.
module Graphics.UI.Qtah.Generator.Interface.Core.QItemSelectionModel (
aModule,
c_QItemSelectionModel,
bs_SelectionFlags,
) where
import Foreign.Hoppy.Generator.Spec (
Export (ExportBitspace, ExportEnum, ExportClass),
addReqIncludes,
classSetEntityPrefix,
ident,
ident1,
includeStd,
makeClass,
mkConstMethod,
mkConstMethod',
mkCtor,
mkMethod,
mkMethod',
)
import Foreign.Hoppy.Generator.Types (
bitspaceT,
boolT,
constT,
intT,
objT,
ptrT,
voidT,
)
import Foreign.Hoppy.Generator.Version (collect, just, test)
import Graphics.UI.Qtah.Generator.Flags (qtVersion)
import Graphics.UI.Qtah.Generator.Interface.Core.QAbstractItemModel (c_QAbstractItemModel)
import Graphics.UI.Qtah.Generator.Interface.Core.QItemSelection (c_QItemSelection)
import Graphics.UI.Qtah.Generator.Interface.Core.QList (c_QListQModelIndex)
import Graphics.UI.Qtah.Generator.Interface.Core.QModelIndex (c_QModelIndex)
import Graphics.UI.Qtah.Generator.Interface.Core.QObject (c_QObject)
import Graphics.UI.Qtah.Generator.Interface.Internal.Listener (
c_ListenerPtrQAbstractItemModel,
c_ListenerRefConstQItemSelectionRefConstQItemSelection,
c_ListenerQModelIndexQModelIndex,
)
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModule)
import Graphics.UI.Qtah.Generator.Types
{-# ANN module "HLint: ignore Use camelCase" #-}
aModule =
AQtModule $
makeQtModule ["Core", "QItemSelectionModel"] $
[ QtExport $ ExportClass c_QItemSelectionModel ] ++
map QtExportSignal signals ++
[ QtExport $ ExportEnum e_SelectionFlag
, QtExport $ ExportBitspace bs_SelectionFlags
]
c_QItemSelectionModel =
addReqIncludes [includeStd "QItemSelectionModel"] $
classSetEntityPrefix "" $
makeClass (ident "QItemSelectionModel") Nothing [c_QObject] $
collect
[ -- The nullary constructor requires at least Qt >=5.0. Release notes[1]
-- point at QItemSelectionModel gaining some methods in 5.5:
--
-- QAbstractItemModel* model()
-- void modelChanged(QAbstractItemModel* model)
-- void setModel(QAbstractItemModel* model)
--
-- So I suspect that this constructor appeared at that point.
--
-- [1] https://doc.qt.io/qt-5/newclasses55.html
test (qtVersion >= [5, 5]) $ mkCtor "new" []
, just $ mkCtor "newWithModel" [ptrT $ objT c_QAbstractItemModel]
, just $ mkCtor "newWithModelAndParent" [ptrT $ objT c_QAbstractItemModel, ptrT $ objT c_QObject]
, just $ mkMethod "clear" [] voidT
, test (qtVersion >= [5, 0]) $ mkMethod "clearCurrentIndex" [] voidT
, just $ mkMethod "clearSelection" [] voidT
, just $ mkConstMethod "columnIntersectsSelection" [intT, objT c_QModelIndex] boolT
, just $ mkConstMethod "currentIndex" [] $ objT c_QModelIndex
, just $ mkConstMethod "hasSelection" [] boolT
, just $ mkConstMethod "isColumnSelected" [intT, objT c_QModelIndex] boolT
, just $ mkConstMethod "isRowSelected" [intT, objT c_QModelIndex] boolT
, just $ mkConstMethod "isSelected" [objT c_QModelIndex] boolT
, test (qtVersion >= [5, 5]) $ mkMethod' "model" "model" [] $ ptrT $ objT c_QAbstractItemModel
, just $ mkConstMethod' "model" "modelConst" [] $ ptrT $ constT $ objT c_QAbstractItemModel
, just $ mkMethod "reset" [] voidT
, just $ mkConstMethod "rowIntersectsSelection" [intT, objT c_QModelIndex] boolT
, just $ mkMethod' "select" "selectIndex" [objT c_QModelIndex, bitspaceT bs_SelectionFlags] voidT
, just $ mkMethod' "select" "selectSelection" [objT c_QItemSelection, bitspaceT bs_SelectionFlags]
voidT
, just $ mkConstMethod "selectedColumns" [intT] $ objT c_QListQModelIndex
, test (qtVersion >= [5, 5]) $ mkConstMethod "selectedIndexes" [] $ objT c_QListQModelIndex
, just $ mkConstMethod "selectedRows" [intT] $ objT c_QListQModelIndex
, just $ mkConstMethod "selection" [] $ objT c_QItemSelection
, just $ mkMethod "setCurrentIndex" [objT c_QModelIndex, bitspaceT bs_SelectionFlags] voidT
, test (qtVersion >= [5, 5]) $ mkMethod "setModel" [ptrT $ objT c_QAbstractItemModel] voidT
]
signals =
collect
[ just $ makeSignal c_QItemSelectionModel "currentChanged" c_ListenerQModelIndexQModelIndex
, just $ makeSignal c_QItemSelectionModel "currentColumnChanged" c_ListenerQModelIndexQModelIndex
, just $ makeSignal c_QItemSelectionModel "currentRowChanged" c_ListenerQModelIndexQModelIndex
, test (qtVersion >= [5, 5]) $ makeSignal c_QItemSelectionModel "modelChanged"
c_ListenerPtrQAbstractItemModel
, just $ makeSignal c_QItemSelectionModel "selectionChanged"
c_ListenerRefConstQItemSelectionRefConstQItemSelection
]
(e_SelectionFlag, bs_SelectionFlags) =
makeQtEnumBitspace (ident1 "QItemSelectionModel" "SelectionFlag") "SelectionFlags"
[includeStd "QItemSelectionModel"]
[ (0x00, ["no", "update"])
-- Renamed from just "clear" because it clashes with the "clear" method.
, (0x01, ["clear", "flag"])
, (0x02, ["select"])
, (0x04, ["deselect"])
, (0x08, ["toggle"])
, (0x10, ["current"])
, (0x20, ["rows"])
, (0x40, ["columns"])
, (0x12, ["select", "current"])
, (0x18, ["toggle", "current"])
, (0x03, ["clear", "and", "select"])
]
-- This file is part of Qtah.
--
-- Copyright 2017 Bryan Gardiner <bog@khumba.net>
--
-- 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/>.
module Graphics.UI.Qtah.Generator.Interface.Core.QItemSelectionModel (
bs_SelectionFlags,
) where
import Foreign.Hoppy.Generator.Spec (Bitspace)
bs_SelectionFlags :: Bitspace
-- This file is part of Qtah.
--
-- Copyright 2017 Bryan Gardiner <bog@khumba.net>
--
-- 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/>.
module Graphics.UI.Qtah.Generator.Interface.Core.QItemSelectionRange (
aModule,
c_QItemSelectionRange,
) where
import Foreign.Hoppy.Generator.Spec (
Export (ExportClass),
addReqIncludes,
classSetConversionToGc,
classSetEntityPrefix,
ident,
includeStd,
makeClass,
mkConstMethod,
mkConstMethod',
mkCtor,
mkMethod,
)
import Foreign.Hoppy.Generator.Spec.ClassFeature (
ClassFeature (Assignable, Copyable, Equatable),
classAddFeatures,
)
import Foreign.Hoppy.Generator.Types (boolT, constT, 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.Core.QList (c_QListQModelIndex)
import {-# SOURCE #-} Graphics.UI.Qtah.Generator.Interface.Core.QAbstractItemModel (
c_QAbstractItemModel,
)
import Graphics.UI.Qtah.Generator.Interface.Core.QModelIndex (c_QModelIndex)
import Graphics.UI.Qtah.Generator.Interface.Core.QPersistentModelIndex (c_QPersistentModelIndex)
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModule)
import Graphics.UI.Qtah.Generator.Types
{-# ANN module "HLint: ignore Use camelCase" #-}
aModule =
AQtModule $
makeQtModule ["Core", "QItemSelectionRange"]
[ QtExport $ ExportClass c_QItemSelectionRange ]
c_QItemSelectionRange =
addReqIncludes [includeStd "QItemSelectionRange"] $
classSetConversionToGc $
classAddFeatures [Assignable, Copyable, Equatable] $
classSetEntityPrefix "" $
makeClass (ident "QItemSelectionRange") Nothing [] $
collect
[ just $ mkCtor "new" []
, just $ mkCtor "newWithIndex" [objT c_QModelIndex]
, just $ mkCtor "newWithIndices" [objT c_QModelIndex, objT c_QModelIndex]
, just $ mkConstMethod "bottom" [] intT
, just $ mkConstMethod "bottomRight" [] $
if qtVersion >= [5, 0]
then refT $ constT $ objT c_QPersistentModelIndex
else objT c_QModelIndex
, just $ mkConstMethod' "contains" "containsIndex" [objT c_QModelIndex] boolT
, just $ mkConstMethod' "contains" "containsBelowParent" [intT, intT, objT c_QModelIndex] boolT
, just $ mkConstMethod "height" [] intT
, just $ mkConstMethod "indexes" [] $ objT c_QListQModelIndex
, just $ mkConstMethod "intersected" [objT c_QItemSelectionRange] $ objT c_QItemSelectionRange
, just $ mkConstMethod "intersects" [objT c_QItemSelectionRange] boolT
, just $ mkConstMethod "isEmpty" [] boolT
, just $ mkConstMethod "isValid" [] boolT
, just $ mkConstMethod "left" [] intT
, just $ mkConstMethod "model" [] $ ptrT $ constT $ objT c_QAbstractItemModel
, just $ mkConstMethod "parent" [] $ objT c_QModelIndex
, just $ mkConstMethod "right" [] intT
, test (qtVersion >= [5, 6]) $ mkMethod "swap" [refT $ objT c_QItemSelectionRange] voidT
, just $ mkConstMethod "top" [] intT
, just $ mkConstMethod "topLeft" [] $
if qtVersion >= [5, 0]
then refT $ constT $ objT c_QPersistentModelIndex
else objT c_QModelIndex
, just $ mkConstMethod "width" [] intT
]
......@@ -23,13 +23,13 @@ module Graphics.UI.Qtah.Generator.Interface.Core.QList (
Options (..),
defaultOptions,
Contents (..),
instantiate,
instantiate',
toExports,
inheritHasContents,
-- * Instantiations
allModules,
c_QListInt,
c_QListQAbstractButton,
c_QListQItemSelectionRange,
c_QListQModelIndex,
c_QListQObject,
c_QListQString,
c_QListQVariant,
......@@ -41,6 +41,7 @@ import Control.Monad (forM_, when)
import Data.Monoid (mconcat, mempty)
#endif
import Foreign.Hoppy.Generator.Language.Haskell (
Generator,
HsTypeSide (HsHsSide),
addImports,
cppTypeToHsTypeAndUse,
......@@ -49,6 +50,7 @@ import Foreign.Hoppy.Generator.Language.Haskell (
prettyPrint,
sayLn,
saysLn,
toHsCastMethodName,
toHsClassEntityName',
toHsDataTypeName,
)
......@@ -89,12 +91,16 @@ import Foreign.Hoppy.Generator.Spec.ClassFeature (
import Foreign.Hoppy.Generator.Types (boolT, constT, intT, objT, ptrT, refT, toGcT, voidT)
import Foreign.Hoppy.Generator.Version (collect, just, test)
import Graphics.UI.Qtah.Generator.Flags (qtVersion)
import Graphics.UI.Qtah.Generator.Interface.Core.QItemSelectionRange (c_QItemSelectionRange)
import Graphics.UI.Qtah.Generator.Interface.Core.QModelIndex (c_QModelIndex)
import Graphics.UI.Qtah.Generator.Interface.Core.QObject (c_QObject)
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.Interface.Imports
import Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractButton (c_QAbstractButton)
import Graphics.UI.Qtah.Generator.Interface.Widgets.QWidget (c_QWidget)
import {-# SOURCE #-} Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractButton (
c_QAbstractButton,
)
import {-# SOURCE #-} Graphics.UI.Qtah.Generator.Interface.Widgets.QWidget (c_QWidget)
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), QtModule, makeQtModule)
import Graphics.UI.Qtah.Generator.Types
import Language.Haskell.Syntax (
......@@ -258,6 +264,22 @@ instantiate' listName t tReqs opts =
{ c_QList = list
}
-- | Used in an addendum for a class that inherits from QList, this generates a
-- HasContents instance that uses the HasContents instance on the parent list
-- class.
inheritHasContents :: Class -> Class -> Type -> Generator ()
inheritHasContents cls listClass t =
forM_ [Const, Nonconst] $ \cst -> do
hsDataTypeName <- toHsDataTypeName cst cls
hsValueType <- cppTypeToHsTypeAndUse HsHsSide $ case cst of
Const -> constT t
Nonconst -> t
castToListFn <- toHsCastMethodName cst listClass
addImports importForRuntime
saysLn ["instance QtahFHR.HasContents ", hsDataTypeName,
" (", prettyPrint hsValueType, ") where"]
indent $ saysLn ["toContents = QtahFHR.toContents . ", castToListFn]
-- | Converts an instantiation into a list of exports to be included in a
-- module.
toExports :: Contents -> [QtExport]
......@@ -271,6 +293,8 @@ allModules =
map AQtModule
[ qmod_Int
, qmod_QAbstractButton
, qmod_QItemSelectionRange
, qmod_QModelIndex
, qmod_QObject
, qmod_QString
, qmod_QVariant
......@@ -296,6 +320,25 @@ contents_QAbstractButton = instantiate "QListQAbstractButton" (ptrT $ objT c_QAb
c_QListQAbstractButton :: Class
c_QListQAbstractButton = c_QList contents_QAbstractButton
qmod_QItemSelectionRange :: QtModule
qmod_QItemSelectionRange = createModule "QItemSelectionRange" contents_QItemSelectionRange
contents_QItemSelectionRange :: Contents
contents_QItemSelectionRange =
instantiate "QListQItemSelectionRange" (objT c_QItemSelectionRange) mempty
c_QListQItemSelectionRange :: Class
c_QListQItemSelectionRange = c_QList contents_QItemSelectionRange
qmod_QModelIndex :: QtModule
qmod_QModelIndex = createModule "QModelIndex" contents_QModelIndex
contents_QModelIndex :: Contents
contents_QModelIndex = instantiate "QListQModelIndex" (objT c_QModelIndex) mempty
c_QListQModelIndex :: Class
c_QListQModelIndex = c_QList contents_QModelIndex
qmod_QObject :: QtModule
qmod_QObject = createModule "QObject" contents_QObject
......
......@@ -17,9 +17,12 @@
-- | Bindings for @QList@.
module Graphics.UI.Qtah.Generator.Interface.Core.QList (
c_QListQModelIndex,
c_QListQObject,
) where
import Foreign.Hoppy.Generator.Spec (Class)
c_QListQModelIndex :: Class
c_QListQObject :: Class
-- This file is part of Qtah.
--
-- Copyright 2017 Bryan Gardiner <bog@khumba.net>
--
-- 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/>.
module Graphics.UI.Qtah.Generator.Interface.Core.QPersistentModelIndex (
aModule,
c_QPersistentModelIndex,
) where
import Foreign.Hoppy.Generator.Spec (
Export (ExportClass),
addReqIncludes,
classSetEntityPrefix,
classSetConversionToGc,
ident,
includeStd,
makeClass,
mkConstMethod,
mkConstMethod',
mkCtor,
mkMethod,
)
import Foreign.Hoppy.Generator.Spec.ClassFeature (
ClassFeature (Assignable, Copyable, Equatable),
classAddFeatures,
)
import Foreign.Hoppy.Generator.Types (
bitspaceT,
boolT,
constT,
enumT,
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.Core.QAbstractItemModel (
c_QAbstractItemModel,
)
import Graphics.UI.Qtah.Generator.Interface.Core.QModelIndex (c_QModelIndex)
import {-# SOURCE #-} Graphics.UI.Qtah.Generator.Interface.Core.QVariant (c_QVariant)
import Graphics.UI.Qtah.Generator.Interface.Core.Types (bs_ItemFlags, e_ItemDataRole)
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModule)
import Graphics.UI.Qtah.Generator.Types
{-# ANN module "HLint: ignore Use camelCase" #-}
aModule =
AQtModule $
makeQtModule ["Core", "QPersistentModelIndex"]
[ QtExport $ ExportClass c_QPersistentModelIndex ]
c_QPersistentModelIndex =
addReqIncludes [includeStd "QPersistentModelIndex"] $
classSetConversionToGc $
classAddFeatures [Assignable, Copyable, Equatable] $
classSetEntityPrefix "" $
makeClass (ident "QPersistentModelIndex") Nothing [] $
collect
[ just $ mkCtor "new" []
, just $ mkCtor "newFromIndex" [objT c_QModelIndex]
, just $ mkConstMethod "child" [intT, intT] $ objT c_QPersistentModelIndex
, just $ mkConstMethod "column" [] intT
, just $ mkConstMethod' "data" "getData" [] $ objT c_QVariant
, just $ mkConstMethod' "data" "getDataWithRole" [enumT e_ItemDataRole] $ objT c_QVariant
, test (qtVersion >= [4, 2]) $ mkConstMethod "flags" [] $ bitspaceT bs_ItemFlags
, just $ mkConstMethod "isValid" [] boolT
, just $ mkConstMethod "model" [] $ ptrT $ constT $ objT c_QAbstractItemModel
, just $ mkConstMethod "parent" [] $ objT c_QPersistentModelIndex
, just $ mkConstMethod "row" [] intT
, just $ mkConstMethod "sibling" [intT, intT] $ objT c_QPersistentModelIndex
, test (qtVersion >= [5, 0]) $ mkMethod "swap" [refT $ objT c_QPersistentModelIndex] voidT
-- TODO operator const QModelIndex&()
]
......@@ -23,9 +23,6 @@ module Graphics.UI.Qtah.Generator.Interface.Core.QVector (
Options (..),
defaultOptions,
Contents (..),
instantiate,
instantiate',
toExports,
-- * Instantiations
allModules,
c_QVectorInt,
......
......@@ -28,6 +28,8 @@ module Graphics.UI.Qtah.Generator.Interface.Core.Types (
e_CheckState,
e_Corner,
e_CursorMoveStyle,
e_DropAction,
bs_DropActions,
e_EventPriority,
e_FillRule,