Skip to content

Commit dbff07c

Browse files
committed
Style
1 parent 15fed4a commit dbff07c

1 file changed

Lines changed: 63 additions & 44 deletions

File tree

ff-qtah/FF/Qt/DateComponent.hs

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,71 +3,90 @@
33
module FF.Qt.DateComponent (DateComponent, new) where
44

55
-- global
6-
import Foreign (castPtr)
7-
import Foreign.Hoppy.Runtime (CppPtr, nullptr, toPtr, touchCppPtr,
8-
withCppPtr)
9-
import Graphics.UI.Qtah.Core.QObject (QObjectConstPtr, QObjectPtr,
10-
toQObject, toQObjectConst)
11-
import qualified Graphics.UI.Qtah.Widgets.QAbstractSpinBox as QAbstractSpinBox
12-
import qualified Graphics.UI.Qtah.Widgets.QBoxLayout as QBoxLayout
13-
import Graphics.UI.Qtah.Widgets.QDateEdit (QDateEdit)
14-
import qualified Graphics.UI.Qtah.Widgets.QDateEdit as QDateEdit
15-
import qualified Graphics.UI.Qtah.Widgets.QDateTimeEdit as QDateTimeEdit
16-
import Graphics.UI.Qtah.Widgets.QHBoxLayout (QHBoxLayout)
17-
import qualified Graphics.UI.Qtah.Widgets.QHBoxLayout as QHBoxLayout
18-
import Graphics.UI.Qtah.Widgets.QLabel (QLabel)
19-
import qualified Graphics.UI.Qtah.Widgets.QLabel as QLabel
20-
import Graphics.UI.Qtah.Widgets.QLayout (QLayoutConstPtr, QLayoutPtr,
21-
toQLayout, toQLayoutConst)
22-
import Graphics.UI.Qtah.Widgets.QLayoutItem (QLayoutItemConstPtr,
23-
QLayoutItemPtr,
24-
toQLayoutItem,
25-
toQLayoutItemConst)
26-
27-
data DateComponent =
28-
DateComponent{super :: QHBoxLayout, label :: QLabel, dateEdit :: QDateEdit}
6+
import Foreign (castPtr)
7+
import Foreign.Hoppy.Runtime (
8+
CppPtr,
9+
nullptr,
10+
toPtr,
11+
touchCppPtr,
12+
withCppPtr,
13+
)
14+
import Graphics.UI.Qtah.Core.QObject (
15+
QObjectConstPtr,
16+
QObjectPtr,
17+
toQObject,
18+
toQObjectConst,
19+
)
20+
import Graphics.UI.Qtah.Widgets.QAbstractSpinBox qualified as QAbstractSpinBox
21+
import Graphics.UI.Qtah.Widgets.QBoxLayout qualified as QBoxLayout
22+
import Graphics.UI.Qtah.Widgets.QDateEdit (QDateEdit)
23+
import Graphics.UI.Qtah.Widgets.QDateEdit qualified as QDateEdit
24+
import Graphics.UI.Qtah.Widgets.QDateTimeEdit qualified as QDateTimeEdit
25+
import Graphics.UI.Qtah.Widgets.QHBoxLayout (QHBoxLayout)
26+
import Graphics.UI.Qtah.Widgets.QHBoxLayout qualified as QHBoxLayout
27+
import Graphics.UI.Qtah.Widgets.QLabel (QLabel)
28+
import Graphics.UI.Qtah.Widgets.QLabel qualified as QLabel
29+
import Graphics.UI.Qtah.Widgets.QLayout (
30+
QLayoutConstPtr,
31+
QLayoutPtr,
32+
toQLayout,
33+
toQLayoutConst,
34+
)
35+
import Graphics.UI.Qtah.Widgets.QLayoutItem (
36+
QLayoutItemConstPtr,
37+
QLayoutItemPtr,
38+
toQLayoutItem,
39+
toQLayoutItemConst,
40+
)
41+
42+
data DateComponent = DateComponent
43+
{ super :: QHBoxLayout
44+
, label :: QLabel
45+
, dateEdit :: QDateEdit
46+
}
2947

3048
instance CppPtr DateComponent where
31-
nullptr = DateComponent{super = nullptr, label = nullptr, dateEdit = nullptr}
32-
withCppPtr DateComponent{super} proc = withCppPtr super $ proc . castPtr
33-
toPtr = castPtr . toPtr . super
34-
touchCppPtr = touchCppPtr . super
49+
nullptr =
50+
DateComponent{super = nullptr, label = nullptr, dateEdit = nullptr}
51+
withCppPtr DateComponent{super} proc = withCppPtr super $ proc . castPtr
52+
toPtr = castPtr . toPtr . super
53+
touchCppPtr = touchCppPtr . super
3554

3655
instance QObjectConstPtr DateComponent where
37-
toQObjectConst = toQObjectConst . super
56+
toQObjectConst = toQObjectConst . super
3857

3958
instance QObjectPtr DateComponent where
40-
toQObject = toQObject . super
59+
toQObject = toQObject . super
4160

4261
instance QLayoutItemConstPtr DateComponent where
43-
toQLayoutItemConst = toQLayoutItemConst . super
62+
toQLayoutItemConst = toQLayoutItemConst . super
4463

4564
instance QLayoutItemPtr DateComponent where
46-
toQLayoutItem = toQLayoutItem . super
65+
toQLayoutItem = toQLayoutItem . super
4766

4867
instance QLayoutConstPtr DateComponent where
49-
toQLayoutConst = toQLayoutConst . super
68+
toQLayoutConst = toQLayoutConst . super
5069

5170
instance QLayoutPtr DateComponent where
52-
toQLayout = toQLayout . super
71+
toQLayout = toQLayout . super
5372

5473
new :: String -> IO DateComponent
5574
new title = do
56-
super <- QHBoxLayout.new
75+
super <- QHBoxLayout.new
5776

58-
label <- QLabel.newWithText title
59-
QBoxLayout.addWidget super label
77+
label <- QLabel.newWithText title
78+
QBoxLayout.addWidget super label
6079

61-
dateEdit <- QDateEdit.new
62-
QDateTimeEdit.setCalendarPopup dateEdit True
63-
QBoxLayout.addWidget super dateEdit
80+
dateEdit <- QDateEdit.new
81+
QDateTimeEdit.setCalendarPopup dateEdit True
82+
QBoxLayout.addWidget super dateEdit
6483

65-
QBoxLayout.addStretch super
84+
QBoxLayout.addStretch super
6685

67-
let this = DateComponent{super, label, dateEdit}
68-
setEditable this False
69-
pure this
86+
let this = DateComponent{super, label, dateEdit}
87+
setEditable this False
88+
pure this
7089

7190
setEditable :: DateComponent -> Bool -> IO ()
7291
setEditable DateComponent{dateEdit} editable =
73-
QAbstractSpinBox.setReadOnly dateEdit $ not editable
92+
QAbstractSpinBox.setReadOnly dateEdit $ not editable

0 commit comments

Comments
 (0)