|
3 | 3 | module FF.Qt.DateComponent (DateComponent, new) where |
4 | 4 |
|
5 | 5 | -- 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 | + } |
29 | 47 |
|
30 | 48 | 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 |
35 | 54 |
|
36 | 55 | instance QObjectConstPtr DateComponent where |
37 | | - toQObjectConst = toQObjectConst . super |
| 56 | + toQObjectConst = toQObjectConst . super |
38 | 57 |
|
39 | 58 | instance QObjectPtr DateComponent where |
40 | | - toQObject = toQObject . super |
| 59 | + toQObject = toQObject . super |
41 | 60 |
|
42 | 61 | instance QLayoutItemConstPtr DateComponent where |
43 | | - toQLayoutItemConst = toQLayoutItemConst . super |
| 62 | + toQLayoutItemConst = toQLayoutItemConst . super |
44 | 63 |
|
45 | 64 | instance QLayoutItemPtr DateComponent where |
46 | | - toQLayoutItem = toQLayoutItem . super |
| 65 | + toQLayoutItem = toQLayoutItem . super |
47 | 66 |
|
48 | 67 | instance QLayoutConstPtr DateComponent where |
49 | | - toQLayoutConst = toQLayoutConst . super |
| 68 | + toQLayoutConst = toQLayoutConst . super |
50 | 69 |
|
51 | 70 | instance QLayoutPtr DateComponent where |
52 | | - toQLayout = toQLayout . super |
| 71 | + toQLayout = toQLayout . super |
53 | 72 |
|
54 | 73 | new :: String -> IO DateComponent |
55 | 74 | new title = do |
56 | | - super <- QHBoxLayout.new |
| 75 | + super <- QHBoxLayout.new |
57 | 76 |
|
58 | | - label <- QLabel.newWithText title |
59 | | - QBoxLayout.addWidget super label |
| 77 | + label <- QLabel.newWithText title |
| 78 | + QBoxLayout.addWidget super label |
60 | 79 |
|
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 |
64 | 83 |
|
65 | | - QBoxLayout.addStretch super |
| 84 | + QBoxLayout.addStretch super |
66 | 85 |
|
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 |
70 | 89 |
|
71 | 90 | setEditable :: DateComponent -> Bool -> IO () |
72 | 91 | setEditable DateComponent{dateEdit} editable = |
73 | | - QAbstractSpinBox.setReadOnly dateEdit $ not editable |
| 92 | + QAbstractSpinBox.setReadOnly dateEdit $ not editable |
0 commit comments