2017-04-27 18:26:05 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-09-03 16:57:38 +00: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 18:54:24 +00:00
|
|
|
#include "ui_tableview.h"
|
|
|
|
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "core/metrics.h"
|
2014-10-15 13:30:52 +00:00
|
|
|
|
2013-09-03 16:57:38 +00:00
|
|
|
class QPushButton;
|
|
|
|
class QAbstractItemModel;
|
|
|
|
class QModelIndex;
|
|
|
|
class QTableView;
|
|
|
|
|
2014-10-17 19:22:49 +00:00
|
|
|
class TableView : public QGroupBox {
|
2014-02-28 04:09:57 +00:00
|
|
|
Q_OBJECT
|
2014-10-15 13:30:48 +00:00
|
|
|
|
|
|
|
struct TableMetrics {
|
2014-10-15 13:30:52 +00:00
|
|
|
const IconMetrics* icon; // icon metrics
|
2014-10-15 13:30:48 +00:00
|
|
|
int rm_col_width; // column width of REMOVE column
|
|
|
|
int header_ht; // height of the header
|
|
|
|
};
|
2013-09-03 16:57:38 +00:00
|
|
|
public:
|
|
|
|
TableView(QWidget *parent = 0);
|
|
|
|
virtual ~TableView();
|
|
|
|
/* The model is expected to have a 'remove' slot, that takes a QModelIndex as parameter.
|
|
|
|
* It's also expected to have the column '1' as a trash icon. I most probably should create a
|
|
|
|
* proxy model and add that column, will mark that as TODO. see? marked.
|
|
|
|
*/
|
2014-02-28 04:09:57 +00:00
|
|
|
void setModel(QAbstractItemModel *model);
|
|
|
|
void setBtnToolTip(const QString &tooltip);
|
2013-09-03 16:57:38 +00:00
|
|
|
void fixPlusPosition();
|
2014-02-28 04:09:57 +00:00
|
|
|
void edit(const QModelIndex &index);
|
2014-10-15 13:30:48 +00:00
|
|
|
int defaultColumnWidth(int col); // default column width for column col
|
2013-09-03 16:57:38 +00:00
|
|
|
QTableView *view();
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2013-09-03 16:57:38 +00:00
|
|
|
protected:
|
2014-02-28 04:09:57 +00:00
|
|
|
virtual void showEvent(QShowEvent *);
|
|
|
|
virtual void resizeEvent(QResizeEvent *);
|
2013-09-03 16:57:38 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void addButtonClicked();
|
|
|
|
|
|
|
|
private:
|
2013-10-15 11:37:31 +00:00
|
|
|
Ui::TableView ui;
|
2013-09-03 16:57:38 +00:00
|
|
|
QPushButton *plusBtn;
|
2014-10-15 13:30:48 +00:00
|
|
|
TableMetrics metrics;
|
2013-09-03 16:57:38 +00:00
|
|
|
};
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // TABLEVIEW_H
|