Apply a bunch of HLint clean-ups.

parent abb49322
......@@ -160,8 +160,8 @@ findQmake programDb verbosity = do
generatorConfiguredProgram <-
maybe (dieFn $ packageName ++ ": Couldn't find qtah-generator. Is it installed?") return $
lookupProgram generatorProgram programDb
output <- fmap lines $
getProgramOutput verbosity generatorConfiguredProgram ["--qmake-executable"]
output <-
lines <$> getProgramOutput verbosity generatorConfiguredProgram ["--qmake-executable"]
case output of
executable:args -> return (executable, args)
[] -> fail $ packageName ++
......@@ -321,10 +321,12 @@ exportQtVersion configFlags localBuildInfo = do
#endif
qt4Flag = fromMaybe False $ lookupFlag (mkFlagName "qt4") flags
qt5Flag = fromMaybe False $ lookupFlag (mkFlagName "qt5") flags
qtFlag = if qt4Flag then Just 4 else if qt5Flag then Just 5 else Nothing
qtFlag | qt4Flag = Just 4
| qt5Flag = Just 5
| otherwise = Nothing
when (qt4Flag && qt5Flag) $
dieFn $ concat
[packageName, ": The qt4 and qt5 flags are mutually exclusive. Please select at most one."]
dieFn $
packageName ++ ": The qt4 and qt5 flags are mutually exclusive. Please select at most one."
-- Inspect the QTAH_QT environment variable.
qtahQtStr <- lookupEnv "QTAH_QT"
......@@ -341,8 +343,7 @@ exportQtVersion configFlags localBuildInfo = do
-- generator to pick up.
case (qtahQtMajor, qtFlag) of
-- If both QTAH_QT and one of the qtX flags above is set, then they must agree.
(Just m, Just n) -> do
when (m /= n) $
(Just m, Just n) | m /= n ->
dieFn $ concat
[packageName, ": QTAH_QT=", show $ fromMaybe "" qtahQtStr, " and the qt",
show n, " flag conflict."]
......@@ -360,7 +361,7 @@ exportQtVersion configFlags localBuildInfo = do
(_, Just n) ->
notice verbosity $
concat [packageName, ": Requesting Qt ", show n, " because of the qt", show n, " flag."]
_ -> notice verbosity $ concat [packageName, ": Requesting system default Qt."]
_ -> notice verbosity $ packageName ++ ": Requesting system default Qt."
return $ qtahQtMajor <|> qtFlag
......
......@@ -108,9 +108,9 @@ wsWince = False
-- qmake binary.
readQt :: IO QtConfig
readQt = do
maybeStr <- fmap (\x -> case x of
maybeStr <- (\x -> case x of
Just "" -> Nothing
_ -> x) $
_ -> x) <$>
lookupEnv "QTAH_QT"
case maybeStr of
Just str -> do
......@@ -147,7 +147,7 @@ readQt = do
qmakeExecutableNamesForVersion major = ["qmake-qt" ++ show major, "qmake"]
queryQmake :: Maybe Int -> IO QtConfig
queryQmake maybePreferredMajorVersion = do
queryQmake maybePreferredMajorVersion =
case maybePreferredMajorVersion of
Nothing ->
-- No major version preference, so take whatever Qt is available.
......
......@@ -36,7 +36,7 @@ import Graphics.UI.Qtah.Generator.Types
aModule =
AQtModule $
makeQtModule ["Core", "QAbstractListModel"] $
makeQtModule ["Core", "QAbstractListModel"]
[ QtExport $ ExportClass c_QAbstractListModel ]
c_QAbstractListModel =
......
......@@ -36,7 +36,7 @@ import Graphics.UI.Qtah.Generator.Types
aModule =
AQtModule $
makeQtModule ["Core", "QAbstractTableModel"] $
makeQtModule ["Core", "QAbstractTableModel"]
[ QtExport $ ExportClass c_QAbstractTableModel ]
c_QAbstractTableModel =
......
......@@ -80,7 +80,7 @@ c_QItemSelection =
ClassHaskellConversion
{ classHaskellConversionType = Just $ do
hsType <- cppTypeToHsTypeAndUse HsHsSide $ objT c_QItemSelectionRange
return $ HsTyApp (HsTyCon $ Special $ HsListCon) hsType
return $ HsTyApp (HsTyCon $ Special HsListCon) hsType
, classHaskellConversionToCppFn = Nothing
, classHaskellConversionFromCppFn = Just $ do
addImports importForRuntime
......@@ -89,7 +89,7 @@ c_QItemSelection =
addAddendumHaskell
(inheritHasContents c_QItemSelection c_QListQItemSelectionRange $ objT c_QItemSelectionRange) $
classSetEntityPrefix "" $
makeClass (ident "QItemSelection") Nothing [c_QListQItemSelectionRange] $
makeClass (ident "QItemSelection") Nothing [c_QListQItemSelectionRange]
[ mkCtor "new" []
, mkCtor "newWithRange" [objT c_QModelIndex, objT c_QModelIndex]
, mkConstMethod "contains" [objT c_QModelIndex] boolT
......
......@@ -251,9 +251,8 @@ instantiate' listName t tReqs opts =
-- type using HasContents/FromContents.
conversion =
ClassHaskellConversion
{ classHaskellConversionType = Just $ do
hsType <- cppTypeToHsTypeAndUse HsHsSide t
return $ HsTyApp (HsTyCon $ Special HsListCon) hsType
{ classHaskellConversionType =
Just $ HsTyApp (HsTyCon $ Special HsListCon) <$> cppTypeToHsTypeAndUse HsHsSide t
, classHaskellConversionToCppFn = Just $ do
addImports importForRuntime
sayLn "QtahFHR.fromContents"
......
......@@ -57,7 +57,7 @@ c_QMetaClassInfo =
classSetConversionToGc $
classAddFeatures [Copyable] $
classSetEntityPrefix "" $
makeClass (ident "QMetaClassInfo") Nothing [] $
makeClass (ident "QMetaClassInfo") Nothing []
[ makeFnMethod (ident2 "qtah" "qmetaclassinfo" "name") "name" MConst Nonpure
[objT c_QMetaClassInfo] $ objT c_QString
, makeFnMethod (ident2 "qtah" "qmetaclassinfo" "value") "value" MConst Nonpure
......
......@@ -61,8 +61,8 @@ import Graphics.UI.Qtah.Generator.Types
aModule =
AQtModule $
makeQtModule ["Core", "QObject"] $
[ QtExport $ ExportClass c_QObject
] ++ map QtExportSignal signals
(QtExport $ ExportClass c_QObject) :
map QtExportSignal signals
c_QObject =
addReqIncludes [ includeStd "QObject"
......
......@@ -88,7 +88,7 @@ c_QStringList =
{ classHaskellConversionType = Just $ do
addImports importForPrelude
return $
HsTyApp (HsTyCon $ Special $ HsListCon) $
HsTyApp (HsTyCon $ Special HsListCon) $
HsTyCon $ UnQual $ HsIdent "QtahP.String"
, classHaskellConversionToCppFn = Just $ do
addImports importForRuntime
......
......@@ -41,7 +41,7 @@ import Graphics.UI.Qtah.Generator.Types
aModule =
AQtModule $
makeQtModule ["Core", "QStringListModel"] $
makeQtModule ["Core", "QStringListModel"]
[ QtExport $ ExportClass c_QStringListModel ]
c_QStringListModel =
......
......@@ -59,7 +59,7 @@ c_QBrush =
classSetConversionToGc $
classAddFeatures [Assignable, Copyable, Equatable] $
classSetEntityPrefix "" $
makeClass (ident "QBrush") Nothing [] $
makeClass (ident "QBrush") Nothing []
[ mkCtor "new" []
, mkCtor "newWithColor" [objT c_QColor]
, mkProp "color" $ objT c_QColor
......
......@@ -112,12 +112,12 @@ c_QIcon =
, just $ mkConstMethod "isNull" [] boolT
, just $ mkConstMethod "name" [] $ objT c_QString
, just $ mkConstMethod' "paint" "paintWithRect"
[ptrT $ objT c_QPainter, objT c_QRect] $ voidT
[ptrT $ objT c_QPainter, objT c_QRect] voidT
, just $ mkConstMethod' "paint" "paintWithRectAll"
[ptrT $ objT c_QPainter, objT c_QRect, bitspaceT bs_Alignment, enumT e_Mode, enumT e_State]
voidT
, just $ mkConstMethod' "paint" "paintWithRaw"
[ptrT $ objT c_QPainter, intT, intT, intT, intT] $ voidT
[ptrT $ objT c_QPainter, intT, intT, intT, intT] voidT
, just $ mkConstMethod' "paint" "paintWithRawAll"
[ptrT $ objT c_QPainter, intT, intT, intT, intT, bitspaceT bs_Alignment, enumT e_Mode,
enumT e_State]
......
......@@ -249,7 +249,7 @@ c_QImage =
]
e_Format =
makeQtEnum (ident1 "QImage" "Format") [includeStd "QImage"] $
makeQtEnum (ident1 "QImage" "Format") [includeStd "QImage"]
[ (0, ["format", "invalid"])
, (1, ["format", "mono"])
, (2, ["format", "mono", "l", "s", "b"])
......@@ -278,7 +278,7 @@ e_Format =
]
e_InvertMode =
makeQtEnum (ident1 "QImage" "InvertMode") [includeStd "QImage"] $
makeQtEnum (ident1 "QImage" "InvertMode") [includeStd "QImage"]
[ (0, ["invert", "rgb"])
, (1, ["invert", "rgba"])
]
......@@ -41,7 +41,7 @@ import Graphics.UI.Qtah.Generator.Types
aModule =
AQtModule $
makeQtModule ["Gui", "QIntValidator"] $
makeQtModule ["Gui", "QIntValidator"]
[ QtExport $ ExportClass c_QIntValidator ]
c_QIntValidator =
......
......@@ -68,7 +68,7 @@ c_QPaintDevice =
]
e_PaintDeviceMetric =
makeQtEnum (ident1 "QPaintDevice" "PaintDeviceMetric") [includeStd "QPaintDevice"] $
makeQtEnum (ident1 "QPaintDevice" "PaintDeviceMetric") [includeStd "QPaintDevice"]
[ (1, ["pdm", "width"])
, (2, ["pdm", "height"])
, (3, ["pdm", "width", "mm"])
......
......@@ -48,11 +48,11 @@ import Graphics.UI.Qtah.Generator.Types
aModule =
AQtModule $
makeQtModule ["Gui", "QPainter"] $
(QtExport $ ExportClass c_QPainter) :
(QtExport $ ExportEnum e_RenderHint) :
(QtExport $ ExportBitspace bs_RenderHints) :
[]
makeQtModule ["Gui", "QPainter"]
[ QtExport $ ExportClass c_QPainter
, QtExport $ ExportEnum e_RenderHint
, QtExport $ ExportBitspace bs_RenderHints
]
c_QPainter =
addReqIncludes [includeStd "QPainter"] $
......@@ -69,7 +69,7 @@ c_QPainter =
]
(e_RenderHint, bs_RenderHints) =
makeQtEnumBitspace (ident1 "QPainter" "RenderHint") "RenderHints" [includeStd "QPainter"] $
makeQtEnumBitspace (ident1 "QPainter" "RenderHint") "RenderHints" [includeStd "QPainter"]
[ (0x01, ["antialiasing"])
, (0x02, ["text","antialiasing"])
, (0x04, ["smooth","pixmap","transform"])
......
......@@ -51,7 +51,7 @@ c_QPen =
classSetConversionToGc $
classAddFeatures [Assignable, Copyable, Equatable] $
classSetEntityPrefix "" $
makeClass (ident "QPen") Nothing [] $
makeClass (ident "QPen") Nothing []
[ mkCtor "new" []
, mkCtor "newWithColor" [objT c_QColor]
]
......@@ -42,7 +42,7 @@ minVersion = [5, 4]
aModule =
AQtModule $
makeQtModuleWithMinVersion ["Gui", "QRasterWindow"] minVersion $
makeQtModuleWithMinVersion ["Gui", "QRasterWindow"] minVersion
[ QtExport $ ExportClass c_QRasterWindow ]
c_QRasterWindow =
......
......@@ -44,7 +44,7 @@ minVersion = [5, 0]
aModule =
AQtModule $
makeQtModuleWithMinVersion ["Gui", "QSurface"] minVersion $
makeQtModuleWithMinVersion ["Gui", "QSurface"] minVersion
[ QtExport $ ExportClass c_QSurface
, QtExport $ ExportEnum e_SurfaceClass
, QtExport $ ExportEnum e_SurfaceType
......
......@@ -50,6 +50,6 @@ c_QTransform =
classSetConversionToGc $
classAddFeatures [Assignable, Copyable, Equatable] $
classSetEntityPrefix "" $
makeClass (ident "QTransform") Nothing [] $
makeClass (ident "QTransform") Nothing []
[ mkCtor "new2x2" [qreal, qreal, qreal, qreal, qreal, qreal]
]
......@@ -50,7 +50,7 @@ aModule =
c_QValidator =
addReqIncludes [includeStd "QValidator"] $
classSetEntityPrefix "" $
makeClass (ident "QValidator") Nothing [c_QObject] $
makeClass (ident "QValidator") Nothing [c_QObject]
[ mkConstMethod "fixup" [refT $ objT c_QString] voidT
-- TODO locale
-- TODO setLocale
......
......@@ -45,7 +45,7 @@ import Graphics.UI.Qtah.Generator.Types
aModule =
AQtModule $
makeQtModuleWithMinVersion ["Gui", "QtahOpenGLWindow"] minVersion $
makeQtModuleWithMinVersion ["Gui", "QtahOpenGLWindow"] minVersion
[ QtExport $ ExportClass c_QtahOpenGLWindow ]
c_QtahOpenGLWindow =
......
......@@ -41,7 +41,7 @@ import Graphics.UI.Qtah.Generator.Types
aModule =
AQtModule $
makeQtModuleWithMinVersion ["Gui", "QtahRasterWindow"] minVersion $
makeQtModuleWithMinVersion ["Gui", "QtahRasterWindow"] minVersion
[ QtExport $ ExportClass c_QtahRasterWindow ]
c_QtahRasterWindow =
......
......@@ -53,8 +53,7 @@ aModule =
c_QAbstractButton =
addReqIncludes [includeStd "QAbstractButton"] $
classSetEntityPrefix "" $
makeClass (ident "QAbstractButton") Nothing
[ c_QWidget ] $
makeClass (ident "QAbstractButton") Nothing [c_QWidget]
-- Abstact.
[ mkMethod "animateClick" [intT] voidT
, mkProp "autoExclusive" boolT
......
......@@ -43,7 +43,7 @@ aModule =
c_QAbstractItemDelegate =
addReqIncludes [includeStd "QAbstractItemDelegate"] $
classSetEntityPrefix "" $
makeClass (ident "QAbstractItemDelegate") Nothing [c_QObject] $
makeClass (ident "QAbstractItemDelegate") Nothing [c_QObject]
[ -- TODO Methods.
]
......
......@@ -85,7 +85,7 @@ aModule =
c_QAbstractItemView =
addReqIncludes [includeStd "QAbstractItemView"] $
classSetEntityPrefix "" $
makeClass (ident "QAbstractItemView") Nothing [c_QAbstractScrollArea] $
makeClass (ident "QAbstractItemView") Nothing [c_QAbstractScrollArea]
[ mkProp "alternatingRowColors" boolT
, mkBoolHasProp "autoScroll"
, mkProp "autoScrollMargin" intT
......
......@@ -56,10 +56,10 @@ aModule =
QtExport (ExportClass c_QAction) :
map QtExportSignal signals ++
(map (QtExport . ExportEnum) . collect)
[ just $ e_ActionEvent
, just $ e_MenuRole
, just $ e_Priority
, test (qtVersion < [5]) $ e_SoftKeyRole
[ just e_ActionEvent
, just e_MenuRole
, just e_Priority
, test (qtVersion < [5]) e_SoftKeyRole
]
c_QAction =
......
......@@ -77,7 +77,7 @@ c_QDockWidget =
, just $ mkCtor "newWithTextAndParent" [objT c_QString, ptrT $ objT c_QWidget]
-- TODO Ctor with Qt::WindowFlags.
, just $ mkProp "allowedAreas" $ bitspaceT bs_DockWidgetAreas
, just $ mkConstMethod "isAreaAllowed" [enumT e_DockWidgetArea] $ boolT
, just $ mkConstMethod "isAreaAllowed" [enumT e_DockWidgetArea] boolT
, just $ mkProp "features" $ bitspaceT bs_DockWidgetFeatures
, just $ mkBoolIsProp "floating"
, test (qtVersion >= [4, 3]) $ mkProp "titleBarWidget" $ ptrT $ objT c_QWidget
......@@ -97,7 +97,7 @@ signals =
(e_DockWidgetFeature, bs_DockWidgetFeatures) =
makeQtEnumBitspace (ident1 "QDockWidget" "DockWidgetFeature") "DockWidgetFeatures"
[includeStd "QDockWidget"] $
[includeStd "QDockWidget"]
[ (0x0, ["no", "dock", "widget", "features"])
, (0x1, ["dock", "widget", "closable"])
, (0x2, ["dock", "widget", "movable"])
......
......@@ -174,7 +174,7 @@ e_FileMode =
, just (1, ["existing", "file"])
, just (2, ["directory"])
, just (3, ["existing", "files"])
, test (qtVersion < [4, 5]) $ (4, ["directory", "only"])
, test (qtVersion < [4, 5]) (4, ["directory", "only"])
]
(e_Option, bs_Options) =
......
......@@ -377,23 +377,23 @@ e_GraphicsItemChange =
makeQtEnumBitspace (ident1 "QGraphicsItem" "GraphicsItemFlag") "GraphicsItemFlags"
[includeStd "QGraphicsItem"] $
collect
[ just $ (0x1, ["item","is","movable"])
, just $ (0x2, ["item","is","selectable"])
, just $ (0x4, ["item","is","focusable"])
, just $ (0x8, ["item","clips","to","shape"])
, just $ (0x10, ["item","clips","children","to","shape"])
, just $ (0x20, ["item","ignores","transformations"])
, just $ (0x40, ["item","ignores","parent","opacity"])
, just $ (0x80, ["item","doesnt","propagate","opacity","to","children"])
, just $ (0x100, ["item","stacks","behind","parent"])
, just $ (0x200, ["item","uses","extended","style","option"])
, just $ (0x400, ["item","has","no","contents"])
, just $ (0x800, ["item","sends","geometry","changes"])
, just $ (0x1000, ["item","accepts","input","method"])
, just $ (0x2000, ["item","negative","z","stacks","behind","parent"])
, just $ (0x4000, ["item","is","panel"])
, just $ (0x10000, ["item","sends","scene","position","changes"])
, test (qtVersion >= [5, 4]) $ (0x80000, ["item","contains","children","in","shape"])
[ just (0x1, ["item","is","movable"])
, just (0x2, ["item","is","selectable"])
, just (0x4, ["item","is","focusable"])
, just (0x8, ["item","clips","to","shape"])
, just (0x10, ["item","clips","children","to","shape"])
, just (0x20, ["item","ignores","transformations"])
, just (0x40, ["item","ignores","parent","opacity"])
, just (0x80, ["item","doesnt","propagate","opacity","to","children"])
, just (0x100, ["item","stacks","behind","parent"])
, just (0x200, ["item","uses","extended","style","option"])
, just (0x400, ["item","has","no","contents"])
, just (0x800, ["item","sends","geometry","changes"])
, just (0x1000, ["item","accepts","input","method"])
, just (0x2000, ["item","negative","z","stacks","behind","parent"])
, just (0x4000, ["item","is","panel"])
, just (0x10000, ["item","sends","scene","position","changes"])
, test (qtVersion >= [5, 4]) (0x80000, ["item","contains","children","in","shape"])
]
e_PanelModality =
......
......@@ -45,6 +45,6 @@ aModule =
c_QGraphicsSceneEvent =
addReqIncludes [includeStd "QGraphicsSceneEvent"] $
classSetEntityPrefix "" $
makeClass (ident "QGraphicsSceneEvent") Nothing [c_QEvent] $
makeClass (ident "QGraphicsSceneEvent") Nothing [c_QEvent]
[ mkConstMethod "widget" [] $ ptrT $ objT c_QWidget
]
......@@ -45,8 +45,8 @@ import Graphics.UI.Qtah.Generator.Types
aModule =
AQtModule $
makeQtModule ["Widgets", "QSplitter"] $
[ QtExport $ ExportClass c_QSplitter
] ++ map QtExportSignal signals
(QtExport $ ExportClass c_QSplitter) :
map QtExportSignal signals
c_QSplitter =
addReqIncludes [includeStd "QSplitter"] $
......
......@@ -48,7 +48,7 @@ aModule =
c_QStyledItemDelegate =
addReqIncludes [includeStd "QStyledItemDelegate"] $
classSetEntityPrefix "" $
makeClass (ident "QStyledItemDelegate") Nothing [c_QAbstractItemDelegate] $
makeClass (ident "QStyledItemDelegate") Nothing [c_QAbstractItemDelegate]
[
-- Public Functions
mkCtor "new" []
......
......@@ -289,7 +289,7 @@ sayQtExport path qtExport = case qtExport of
forM_ (bitspaceValueNames b) $ \(_, valueName) ->
addExport $ toHsBitspaceValueName' b valueName
QtExport (ExportFn fn) -> do
QtExport (ExportFn fn) ->
addExport $ getFnReexportName fn
QtExportFnRenamed fn rename -> do
......
......@@ -73,7 +73,7 @@ makeQtEnum identifier includes valueNames =
addReqIncludes includes $
enumSetValuePrefix "" $
makeEnum identifier
(Just $ toExtName $ concat $ map idPartBase $ identifierParts identifier)
(Just $ toExtName $ concatMap idPartBase $ identifierParts identifier)
valueNames
-- | Creates an (enum, bitspace) pair with the same values and similar names,
......
......@@ -342,10 +342,12 @@ exportQtVersion configFlags localBuildInfo = do
#endif
qt4Flag = fromMaybe False $ lookupFlag (mkFlagName "qt4") flags
qt5Flag = fromMaybe False $ lookupFlag (mkFlagName "qt5") flags
qtFlag = if qt4Flag then Just 4 else if qt5Flag then Just 5 else Nothing
qtFlag | qt4Flag = Just 4
| qt5Flag = Just 5
| otherwise = Nothing
when (qt4Flag && qt5Flag) $
dieFn $ concat
[packageName, ": The qt4 and qt5 flags are mutually exclusive. Please select at most one."]
dieFn $
packageName ++ ": The qt4 and qt5 flags are mutually exclusive. Please select at most one."
-- Inspect the QTAH_QT environment variable.
qtahQtStr <- lookupEnv "QTAH_QT"
......@@ -362,8 +364,7 @@ exportQtVersion configFlags localBuildInfo = do
-- generator to pick up.
case (qtahQtMajor, qtFlag) of
-- If both QTAH_QT and one of the qtX flags above is set, then they must agree.
(Just m, Just n) -> do
when (m /= n) $
(Just m, Just n) | m /= n ->
dieFn $ concat
[packageName, ": QTAH_QT=", show $ fromMaybe "" qtahQtStr, " and the qt",
show n, " flag conflict."]
......@@ -381,7 +382,7 @@ exportQtVersion configFlags localBuildInfo = do
(_, Just n) ->
notice verbosity $
concat [packageName, ": Requesting Qt ", show n, " because of the qt", show n, " flag."]
_ -> notice verbosity $ concat [packageName, ": Requesting system default Qt."]
_ -> notice verbosity $ packageName ++ ": Requesting system default Qt."
return $ qtahQtMajor <|> qtFlag
......
......@@ -73,7 +73,7 @@ onAnyEvent :: QObjectPtr target => target -> EventFilter -> IO EventRegistration
onAnyEvent receiver filter = do
liveVar <- newMVar True
listener <- EventListener.new receiver filter $ modifyMVar_ liveVar $ const $ return False
return $ EventRegistration
return EventRegistration
{ regListener = listener
, regLive = liveVar
}
......
......@@ -72,7 +72,7 @@ onAnySceneEvent :: QGraphicsItemPtr target =>
onAnySceneEvent receiver filter = do
liveVar <- newMVar True
listener <- SceneEventListener.new receiver filter $ modifyMVar_ liveVar $ const $ return False
return $ SceneEventRegistration
return SceneEventRegistration
{ regListener = listener
, regLive = liveVar
}
......
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