pgLab/pglab/crud/DataGridWidget.h

28 lines
690 B
C++

#ifndef DATAGRIDWIDGET_H
#define DATAGRIDWIDGET_H
#include <QWidget>
class QAbstractItemModel;
class QSortFilterProxyModel;
class QTableView;
/** Sortable and editable grid shared by the CRUD tab and the query result tab.
*/
class DataGridWidget : public QWidget {
Q_OBJECT
public:
explicit DataGridWidget(QWidget *parent = nullptr);
/// Sets the model to show, sorting is done by a proxy that uses CustomSortRole
void setSourceModel(QAbstractItemModel *model);
QTableView *view() const { return m_view; }
QSortFilterProxyModel *proxy() const { return m_proxy; }
private:
QTableView *m_view = nullptr;
QSortFilterProxyModel *m_proxy = nullptr;
};
#endif // DATAGRIDWIDGET_H