#ifndef ITEMDETAILMAPPER_H #define ITEMDETAILMAPPER_H #include #include #include #include #include "model/metadata.h" class QGridLayout; class QLabel; class QLineEdit; class QDoubleSpinBox; class QSpinBox; class QPushButton; class QAbstractItemModel; class QItemSelectionModel; class QTableView; class ItemDetailMapper : public QWidget { Q_OBJECT public: explicit ItemDetailMapper(QTableView* tableView, QWidget* parent = nullptr); bool submit(); void revert(); signals: void contentChanged(const QString text); private slots: void onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous); void rowsInserted(const QModelIndex& parent, int start, int end); void rowsRemoved(const QModelIndex& parent, int start, int end); void toPrevious(); void toNext(); void updateButtons(int row); void emitContentChanged(const QModelIndex& currentIndex); private: /// *** members *** /// Model stuff QTableView* m_tableView = nullptr; QAbstractItemModel* m_model = nullptr; QItemSelectionModel* m_selectionModel = nullptr; std::unique_ptr m_mapper; /// GUI elements QGridLayout* m_layout; QList m_controlWidgets; QPushButton* m_nextButton; QPushButton* m_previousButton; void setupConnections(); void setupNavigationButtons(); void setupWidgets(); void setupWidgetPairForColumn(const int column); QWidget* createControlWidget(const UserRoles role); QWidget* createComboBox(const UserRoles role); void clearControlWidgets(); void clearLineEdit(const int column); void clearComboBox(const int column); void clearSpinBox(const int column); }; #endif // ITEMDETAILMAPPER_H