| 
									
										
										
										
											2017-04-27 20:26:05 +02:00
										 |  |  | // SPDX-License-Identifier: GPL-2.0
 | 
					
						
							| 
									
										
										
										
											2013-09-03 13:57:38 -03:00
										 |  |  | #ifndef TABLEVIEW_H
 | 
					
						
							|  |  |  | #define TABLEVIEW_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* This TableView is prepared to have the CSS,
 | 
					
						
							|  |  |  |  * the methods to restore / save the state of | 
					
						
							|  |  |  |  * the column widths and the 'plus' button. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #include <QWidget>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-03 11:54:24 -07:00
										 |  |  | #include "ui_tableview.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-04 22:02:03 -07:00
										 |  |  | #include "core/metrics.h"
 | 
					
						
							| 
									
										
										
										
											2014-10-15 15:30:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-03 13:57:38 -03:00
										 |  |  | class QPushButton; | 
					
						
							|  |  |  | class QAbstractItemModel; | 
					
						
							|  |  |  | class QModelIndex; | 
					
						
							|  |  |  | class QTableView; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-17 21:22:49 +02:00
										 |  |  | class TableView : public QGroupBox { | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	Q_OBJECT | 
					
						
							| 
									
										
										
										
											2014-10-15 15:30:48 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	struct TableMetrics { | 
					
						
							| 
									
										
										
										
											2014-10-15 15:30:52 +02:00
										 |  |  | 		const IconMetrics* icon; // icon metrics
 | 
					
						
							| 
									
										
										
										
											2014-10-15 15:30:48 +02:00
										 |  |  | 		int rm_col_width; // column width of REMOVE column
 | 
					
						
							|  |  |  | 		int header_ht; // height of the header
 | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2013-09-03 13:57:38 -03:00
										 |  |  | public: | 
					
						
							|  |  |  | 	TableView(QWidget *parent = 0); | 
					
						
							| 
									
										
										
										
											2018-07-31 07:41:19 +02:00
										 |  |  | 	~TableView(); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	void setModel(QAbstractItemModel *model); | 
					
						
							|  |  |  | 	void setBtnToolTip(const QString &tooltip); | 
					
						
							| 
									
										
										
										
											2013-09-03 13:57:38 -03:00
										 |  |  | 	void fixPlusPosition(); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	void edit(const QModelIndex &index); | 
					
						
							| 
									
										
										
										
											2014-10-15 15:30:48 +02:00
										 |  |  | 	int  defaultColumnWidth(int col); // default column width for column col
 | 
					
						
							| 
									
										
										
										
											2013-09-03 13:57:38 -03:00
										 |  |  | 	QTableView *view(); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-03 13:57:38 -03:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2018-09-29 22:13:44 +02:00
										 |  |  | 	void showEvent(QShowEvent *) override; | 
					
						
							|  |  |  | 	void resizeEvent(QResizeEvent *) override; | 
					
						
							| 
									
										
										
										
											2013-09-03 13:57:38 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | signals: | 
					
						
							|  |  |  | 	void addButtonClicked(); | 
					
						
							| 
									
										
										
										
											2019-11-02 22:52:27 +01:00
										 |  |  | 	void itemClicked(const QModelIndex &); | 
					
						
							| 
									
										
										
										
											2013-09-03 13:57:38 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2013-10-15 04:37:31 -07:00
										 |  |  | 	Ui::TableView ui; | 
					
						
							| 
									
										
										
										
											2013-09-03 13:57:38 -03:00
										 |  |  | 	QPushButton *plusBtn; | 
					
						
							| 
									
										
										
										
											2014-10-15 15:30:48 +02:00
										 |  |  | 	TableMetrics metrics; | 
					
						
							| 
									
										
										
										
											2013-09-03 13:57:38 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-11 19:14:46 +01:00
										 |  |  | #endif // TABLEVIEW_H
 |