Commit 13846b63 authored by Bryan Gardiner's avatar Bryan Gardiner

Minor touch-ups to graphics scene code.

- SceneEventListener: Define sceneEventFilter, not eventFilter.

- QTimer: remainingTime() is Qt 5+.

- QGraphicsEllipseItem, QGraphicsRectItem: Change ctor names.
parent 97e0c414
......@@ -19,6 +19,11 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QEvent>
#include <QGraphicsItem>
#include <QObject>
#include <QPainter>
#include <QStyleOptionGraphicsItem>
#include <QWidget>
#include "b_callback.hpp"
namespace qtah {
......@@ -81,7 +86,7 @@ public:
}
}
virtual bool eventFilter(QGraphicsItem* receiver, QEvent* event) {
virtual bool sceneEventFilter(QGraphicsItem* receiver, QEvent* event) {
return eventCallback_(receiver, event);
}
......@@ -90,8 +95,7 @@ public:
}
virtual QRectF boundingRect() const { return QRectF(); }
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option,
QWidget * widget = 0) { return; }
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* = 0) { return; }
private:
CallbackPtrQGraphicsItemPtrQEventBool eventCallback_;
......
......@@ -32,6 +32,8 @@ import Foreign.Hoppy.Generator.Spec (
mkCtor,
)
import Foreign.Hoppy.Generator.Types (boolT, intT, voidT)
import Foreign.Hoppy.Generator.Version (collect, just, test)
import Graphics.UI.Qtah.Generator.Flags (qtVersion)
import Graphics.UI.Qtah.Generator.Interface.Internal.Listener (c_Listener)
import Graphics.UI.Qtah.Generator.Interface.Core.QObject (c_QObject)
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModule)
......@@ -49,21 +51,22 @@ aModule =
c_QTimer =
addReqIncludes [includeStd "QTimer"] $
classSetEntityPrefix "" $
makeClass (ident "QTimer") Nothing [c_QObject]
[ mkCtor "new" []
, mkConstMethod "interval" [] intT
-- , mkConstMethod "intervalAsDuration" [] $ objT c_std::chrono::milliseconds
, mkConstMethod "isActive" [] boolT
, mkConstMethod "isSingleShot" [] boolT
, mkConstMethod "remainingTime" [] intT
-- , mkConstMethod "remainingTimeAsDuration" [] $ objT c_std::chrono::milliseconds
, mkMethod "setInterval" [intT] voidT
-- , mkMethod' "setInterval" "setInterval" [objT c_std::chrono::milliseconds] voidT
, mkMethod "setSingleShot" [boolT] voidT
-- , mkMethod "setTimerType" [objT c_Qt::TimerType] voidT
, mkMethod "start" [intT] voidT
, mkConstMethod "timerId" [] intT
-- , mkConstMethod "timerType" [] $ objT c_Qt::TimerType
makeClass (ident "QTimer") Nothing [c_QObject] $
collect
[ just $ mkCtor "new" []
, just $ mkConstMethod "interval" [] intT
-- , just $ mkConstMethod "intervalAsDuration" [] $ objT c_std::chrono::milliseconds
, just $ mkConstMethod "isActive" [] boolT
, just $ mkConstMethod "isSingleShot" [] boolT
, test (qtVersion >= [5, 0]) $ mkConstMethod "remainingTime" [] intT
-- , just $ mkConstMethod "remainingTimeAsDuration" [] $ objT c_std::chrono::milliseconds
, just $ mkMethod "setInterval" [intT] voidT
-- , just $ mkMethod' "setInterval" "setInterval" [objT c_std::chrono::milliseconds] voidT
, just $ mkMethod "setSingleShot" [boolT] voidT
-- , just $ mkMethod "setTimerType" [objT c_Qt::TimerType] voidT
, just $ mkMethod "start" [intT] voidT
, just $ mkConstMethod "timerId" [] intT
-- , just $ mkConstMethod "timerType" [] $ objT c_Qt::TimerType
]
s_timeout = makeSignal c_QTimer "timeout" c_Listener
......@@ -18,6 +18,7 @@
module Graphics.UI.Qtah.Generator.Interface.Widgets (modules) where
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractButton as QAbstractButton
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractGraphicsShapeItem as QAbstractGraphicsShapeItem
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractScrollArea as QAbstractScrollArea
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractSlider as QAbstractSlider
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractSpinBox as QAbstractSpinBox
......@@ -34,7 +35,6 @@ import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QDoubleSpinBox as
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QFileDialog as QFileDialog
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QFormLayout as QFormLayout
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QFrame as QFrame
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractGraphicsShapeItem as QAbstractGraphicsShapeItem
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsEllipseItem as QGraphicsEllipseItem
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsItem as QGraphicsItem
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsPolygonItem as QGraphicsPolygonItem
......@@ -81,6 +81,7 @@ import Graphics.UI.Qtah.Generator.Module (AModule)
modules :: [AModule]
modules =
[ QAbstractButton.aModule
, QAbstractGraphicsShapeItem.aModule
, QAbstractScrollArea.aModule
, QAbstractSlider.aModule
, QAbstractSpinBox.aModule
......@@ -97,7 +98,6 @@ modules =
, QFileDialog.aModule
, QFormLayout.aModule
, QFrame.aModule
, QAbstractGraphicsShapeItem.aModule
, QGraphicsEllipseItem.aModule
, QGraphicsItem.aModule
, QGraphicsPolygonItem.aModule
......
......@@ -48,5 +48,5 @@ c_QGraphicsEllipseItem =
classSetEntityPrefix "" $
makeClass (ident "QGraphicsEllipseItem") Nothing [c_QAbstractGraphicsShapeItem]
[ mkCtor "new" []
, mkCtor "newRectRaw" [qreal, qreal, qreal, qreal]
, mkCtor "newWithRaw" [qreal, qreal, qreal, qreal]
]
......@@ -52,7 +52,7 @@ c_QGraphicsRectItem =
classSetEntityPrefix "" $
makeClass (ident "QGraphicsRectItem") Nothing [c_QAbstractGraphicsShapeItem]
[ mkCtor "new" []
, mkCtor "newWithRect" [qreal, qreal, qreal, qreal]
, mkCtor "newWithRaw" [qreal, qreal, qreal, qreal]
, mkConstMethod "rect" [] $ objT c_QRectF
, mkMethod' "setRect" "setRectRaw" [qreal, qreal, qreal, qreal] voidT
]
......@@ -17,26 +17,6 @@
{-# LANGUAGE ExistentialQuantification #-}
-- | General routines for managing 'QEvent's.
-- This file is part of Qtah.
--
-- Copyright 2016-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/>.
{-# LANGUAGE ExistentialQuantification #-}
-- | General routines for managing 'QEvent's.
module Graphics.UI.Qtah.Event (
-- * High-level interface.
......
......@@ -17,27 +17,8 @@
{-# LANGUAGE ExistentialQuantification #-}
-- | General routines for managing 'QEvent's.
-- This file is part of Qtah.
--
-- Copyright 2016-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/>.
{-# LANGUAGE ExistentialQuantification #-}
-- | General routines for managing 'QEvent's.
-- | General routines for managing events for
-- "Graphics.UI.Qtah.Widgets.QGraphicsScene"s.
module Graphics.UI.Qtah.SceneEvent (
-- * High-level interface.
SceneEvent (..),
......@@ -53,15 +34,14 @@ module Graphics.UI.Qtah.SceneEvent (
import Control.Concurrent.MVar (MVar, modifyMVar_, newMVar, readMVar)
import Control.Monad (when)
import Foreign.Hoppy.Runtime (delete)
import Graphics.UI.Qtah.Widgets.QGraphicsScene (addItem)
import Graphics.UI.Qtah.Widgets.QGraphicsItem
(QGraphicsItem, QGraphicsItemPtr, scene, installSceneEventFilter, removeSceneEventFilter)
import Graphics.UI.Qtah.Widgets.QGraphicsItem (QGraphicsItem, QGraphicsItemPtr)
-- Note, Generated import, since the non-Generated import imports this module.
import Graphics.UI.Qtah.Generated.Core.QEvent (QEvent)
import Graphics.UI.Qtah.Internal.SceneEventListener (SceneEventListener)
import qualified Graphics.UI.Qtah.Internal.SceneEventListener as SceneEventListener
-- | A typeclass for Qt event classes (subclasses of @QEvent@).
-- | A typeclass for Qt events within a
-- 'Graphics.UI.Qtah.Widgets.QGraphicsScene.QGraphicsScene'.
class SceneEvent e where
-- | Registers a callback function to be invoked when an event of type @e@ is
-- sent to an object. This is a wrapper around 'onAnySceneEvent', so for details,
......
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