OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
Table.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
9#include "OTCore/Color.h"
10#include "OTGui/TableCfg.h"
11#include "OTGui/TableRange.h"
13
14// Qt header
15#include <QtWidgets/qtablewidget.h>
16
17// std header
18#include <vector>
19
20namespace ot {
21
22 class OT_WIDGETS_API_EXPORT Table : public QTableWidget {
23 Q_OBJECT
25 public:
26 Table(QWidget* _parentWidget = (QWidget*)nullptr);
27 Table(int _rows, int _columns, QWidget* _parentWidget = (QWidget*)nullptr);
28 virtual ~Table();
29
30 // ###########################################################################################################################################################################################################################################################################################################################
31
32 // Setter / Getter
33
34 virtual void setupFromConfig(const TableCfg& _config);
35 virtual TableCfg createConfig(void) const;
36
37 void setContentChanged(bool _changed = true);
38 bool getContentChanged(void) const { return m_contentChanged; };
39
40 void setSelectedCellsBackground(const ot::Color& _color);
41 void setSelectedCellsBackground(const QColor& _color);
42
43 void prepareForDataChange(void);
44
45 Q_SIGNALS:
46 void saveRequested(void);
47
48 // ###########################################################################################################################################################################################################################################################################################################################
49
50 protected:
51 virtual void showEvent(QShowEvent* _event) override;
52 virtual void hideEvent(QHideEvent* _event) override;
53 virtual void contentSaved(void) {};
54 virtual void contentChanged(void) {};
55
56 // ###########################################################################################################################################################################################################################################################################################################################
57
58 private Q_SLOTS:
59 void slotSaveRequested(void);
60 void slotCellDataChanged(int _row, int _column);
61 void slotRestoreColumnSize(int _column);
62 void slotResizeColumnToContent(int _column);
63 void slotRestoreRowSize(int _row);
64 void slotResizeRowToContent(int _row);
65
66 private:
67 void ini(void);
68 void resizeColumnsToContentIfNeeded(void);
69 void resizeRowsToContentIfNeeded(void);
70 void setResizeRequired(void);
71
72 bool m_stopResizing;
73 bool m_resizeRequired;
74 bool m_contentChanged;
75 std::vector<int> m_columnWidthBuffer;
76 std::vector<int> m_rowHeightBuffer;
77 };
78
79}
#define OT_DECL_NOCOPY(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:14
#define OT_WIDGETS_API_EXPORT
Definition OTWidgetsAPIExport.h:12
The Color class is used to represent RGBA colors with integer values.
Definition Color.h:72
Definition TableCfg.h:19
Definition Table.h:22
bool getContentChanged(void) const
Definition Table.h:38
virtual void contentChanged(void)
Definition Table.h:54
virtual void contentSaved(void)
Definition Table.h:53
Definition Connector.h:8