]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/InsertTableWidget.h
Make code a bit easier to read
[lyx.git] / src / frontends / qt / InsertTableWidget.h
1 // -*- C++ -*-
2 /**
3  * \file InsertTableWidget.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12
13 #ifndef INSERTTABLEWIDGET_H
14 #define INSERTTABLEWIDGET_H
15
16 #include <QWidget>
17 #include <QProxyStyle>
18
19 namespace lyx {
20 namespace frontend {
21
22 class GuiView;
23
24 // A proxy style to get rif of the style-specific tool tip delay
25 // (https://forum.qt.io/topic/90403/show-tooltip-immediatly/6)
26 class ProxyStyle : public QProxyStyle
27 {
28 public:
29         using QProxyStyle::QProxyStyle;
30         int styleHint(StyleHint hint, const QStyleOption * option = nullptr,
31                       const QWidget* widget = nullptr,
32                       QStyleHintReturn* returnData = nullptr) const override
33         {
34                 if (hint == QStyle::SH_ToolTip_WakeUpDelay)
35                         return 0;
36                 else if (hint == QStyle::SH_ToolTip_FallAsleepDelay)
37                         return 0;
38                 return QProxyStyle::styleHint(hint, option, widget, returnData);
39         }
40 };
41
42 class InsertTableWidget : public QWidget {
43         Q_OBJECT
44 public:
45
46         InsertTableWidget(QWidget *);
47
48 Q_SIGNALS:
49         //! widget is visible
50         void visible(bool);
51
52 public Q_SLOTS:
53         //! show the widget
54         void show(bool);
55         //! enable/disable parent
56         void updateParent();
57
58 protected Q_SLOTS:
59         void mouseMoveEvent(QMouseEvent *) override;
60         void mouseReleaseEvent(QMouseEvent *) override;
61         void mousePressEvent(QMouseEvent *) override;
62         void paintEvent(QPaintEvent *) override;
63         void hideEvent(QHideEvent * event) override;
64
65 private:
66         //! update the geometry
67         void resetGeometry();
68         //! initialize parameters to default values
69         void init();
70         //! draw the grid
71         void drawGrid(int rows, int cols, QBrush fillBrush, QColor lineColor);
72
73         //! colwidth in pixels
74         int colwidth_;
75         //! rowheight in pixels
76         int rowheight_;
77         //! total rows
78         int rows_;
79         //! minimum number of rows
80         int minrows_;
81         //! total cols
82         int cols_;
83         //! minimum number of cols
84         int mincols_;
85         //! row of pointer
86         int bottom_;
87         //! column of pointer
88         int right_;
89         //! widget under mouse
90         bool underMouse_;
91 };
92
93 } // namespace frontend
94 } // namespace lyx
95
96 #endif // INSERTTABLEWIDGET_H