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"
|
|
|
|
|
2013-09-03 16:57:38 +00:00
|
|
|
class QPushButton;
|
|
|
|
class QAbstractItemModel;
|
|
|
|
class QModelIndex;
|
|
|
|
class QTableView;
|
|
|
|
|
2013-11-12 19:57:33 +00:00
|
|
|
class TableView : public QWidget {
|
2013-09-03 16:57:38 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
TableView(QWidget *parent = 0);
|
|
|
|
virtual ~TableView();
|
|
|
|
void setTitle(const QString& title);
|
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
void setModel(QAbstractItemModel* model);
|
|
|
|
void setBtnToolTip(const QString& tooltip);
|
|
|
|
void fixPlusPosition();
|
|
|
|
void edit(const QModelIndex& index);
|
|
|
|
QTableView *view();
|
|
|
|
protected:
|
2013-10-15 11:37:31 +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-02-11 18:14:46 +00:00
|
|
|
#endif // TABLEVIEW_H
|