Refactored ItemDetailMapper to encapsulate widget creation and their mappings into functions to be able to iterate over meta data to auto generate them. (Only working for string roles for now)
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#include <QStringListModel>
|
||||
#include <QWidget>
|
||||
|
||||
class QGridLayout;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QDoubleSpinBox;
|
||||
@ -18,9 +19,7 @@ class QTableView;
|
||||
class ItemDetailMapper : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ItemDetailMapper(QWidget* parent = nullptr);
|
||||
|
||||
void setModelMappings(QTableView* tableView);
|
||||
explicit ItemDetailMapper(QTableView* tableView, QWidget* parent = nullptr);
|
||||
|
||||
bool submit();
|
||||
void revert();
|
||||
@ -47,14 +46,8 @@ class ItemDetailMapper : public QWidget {
|
||||
std::unique_ptr<QDataWidgetMapper> m_mapper;
|
||||
|
||||
/// GUI elements
|
||||
QLabel* m_nameLabel = nullptr;
|
||||
QLineEdit* m_nameEdit = nullptr;
|
||||
|
||||
QLabel* m_descriptionLabel = nullptr;
|
||||
QLineEdit* m_descriptionEdit = nullptr;
|
||||
|
||||
QLabel* m_infoLabel = nullptr;
|
||||
QLineEdit* m_infoEdit = nullptr;
|
||||
QGridLayout* m_layout;
|
||||
QList<QWidget*> editControls;
|
||||
|
||||
QLabel* m_typeLabel;
|
||||
QComboBox* m_typeBox;
|
||||
@ -68,6 +61,14 @@ class ItemDetailMapper : public QWidget {
|
||||
|
||||
QPushButton* m_nextButton;
|
||||
QPushButton* m_previousButton;
|
||||
|
||||
void setupConnections();
|
||||
void setupLayout();
|
||||
void setupWidgets();
|
||||
|
||||
void addWidgetsWithMapping(const int row);
|
||||
QPair<QWidget*, QWidget*> createWidgetPairForColumn(const int column);
|
||||
void clearEditWidgets();
|
||||
};
|
||||
|
||||
#endif // ITEMDETAILMAPPER_H
|
||||
|
||||
Reference in New Issue
Block a user