Minor refactoring of ItemDetailMapper.
This commit is contained in:
@ -10,7 +10,6 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include "model/metadata.h"
|
|
||||||
|
|
||||||
ItemDetailMapper::ItemDetailMapper(QTableView* tableView, QWidget* parent)
|
ItemDetailMapper::ItemDetailMapper(QTableView* tableView, QWidget* parent)
|
||||||
: QWidget{parent} {
|
: QWidget{parent} {
|
||||||
@ -32,7 +31,6 @@ ItemDetailMapper::ItemDetailMapper(QTableView* tableView, QWidget* parent)
|
|||||||
|
|
||||||
m_mapper->setModel(m_model);
|
m_mapper->setModel(m_model);
|
||||||
|
|
||||||
setupNavigationButtons();
|
|
||||||
setupWidgets();
|
setupWidgets();
|
||||||
|
|
||||||
setupConnections();
|
setupConnections();
|
||||||
@ -111,6 +109,10 @@ void ItemDetailMapper::setupNavigationButtons() {
|
|||||||
|
|
||||||
connect(m_previousButton, &QAbstractButton::clicked, this, &ItemDetailMapper::toPrevious);
|
connect(m_previousButton, &QAbstractButton::clicked, this, &ItemDetailMapper::toPrevious);
|
||||||
connect(m_nextButton, &QAbstractButton::clicked, this, &ItemDetailMapper::toNext);
|
connect(m_nextButton, &QAbstractButton::clicked, this, &ItemDetailMapper::toNext);
|
||||||
|
|
||||||
|
const int nRows = m_layout->rowCount();
|
||||||
|
m_layout->addWidget(m_previousButton, nRows, 0);
|
||||||
|
m_layout->addWidget(m_nextButton, nRows, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemDetailMapper::setupWidgets() {
|
void ItemDetailMapper::setupWidgets() {
|
||||||
@ -119,10 +121,7 @@ void ItemDetailMapper::setupWidgets() {
|
|||||||
for (int i = 0; i < USER_FACING_ROLES.size(); ++i) {
|
for (int i = 0; i < USER_FACING_ROLES.size(); ++i) {
|
||||||
setupWidgetPairForColumn(i);
|
setupWidgetPairForColumn(i);
|
||||||
}
|
}
|
||||||
|
setupNavigationButtons();
|
||||||
const int nRows = m_layout->rowCount();
|
|
||||||
m_layout->addWidget(m_previousButton, nRows, 0);
|
|
||||||
m_layout->addWidget(m_nextButton, nRows, 1);
|
|
||||||
|
|
||||||
setLayout(m_layout);
|
setLayout(m_layout);
|
||||||
}
|
}
|
||||||
@ -147,7 +146,7 @@ void ItemDetailMapper::setupWidgetPairForColumn(const int column) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* ItemDetailMapper::createControlWidget(const int role) {
|
QWidget* ItemDetailMapper::createControlWidget(const UserRoles role) {
|
||||||
QWidget* control;
|
QWidget* control;
|
||||||
if (STRING_ROLES.contains(role)) {
|
if (STRING_ROLES.contains(role)) {
|
||||||
control = new QLineEdit();
|
control = new QLineEdit();
|
||||||
@ -169,7 +168,7 @@ QWidget* ItemDetailMapper::createControlWidget(const int role) {
|
|||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* ItemDetailMapper::createComboBox(const int role) {
|
QWidget* ItemDetailMapper::createComboBox(const UserRoles role) {
|
||||||
QStringListModel* typeModel;
|
QStringListModel* typeModel;
|
||||||
if (role == TypeRole) {
|
if (role == TypeRole) {
|
||||||
typeModel = new QStringListModel(TYPES, this);
|
typeModel = new QStringListModel(TYPES, this);
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include <QDataWidgetMapper>
|
#include <QDataWidgetMapper>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include "model/metadata.h"
|
||||||
|
|
||||||
class QGridLayout;
|
class QGridLayout;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
@ -57,8 +58,8 @@ class ItemDetailMapper : public QWidget {
|
|||||||
void setupWidgets();
|
void setupWidgets();
|
||||||
|
|
||||||
void setupWidgetPairForColumn(const int column);
|
void setupWidgetPairForColumn(const int column);
|
||||||
QWidget* createControlWidget(const int column);
|
QWidget* createControlWidget(const UserRoles role);
|
||||||
QWidget* createComboBox(const int role);
|
QWidget* createComboBox(const UserRoles role);
|
||||||
|
|
||||||
void clearControlWidgets();
|
void clearControlWidgets();
|
||||||
void clearLineEdit(const int column);
|
void clearLineEdit(const int column);
|
||||||
|
|||||||
Reference in New Issue
Block a user