Using QDataWidgetMapper in ItemDetailMapper to work with the model data (current index of the TableView).
This commit is contained in:
@ -4,8 +4,9 @@
|
||||
|
||||
#include "../views/itemdetailmapper.h"
|
||||
|
||||
EditItemDialog::EditItemDialog(QWidget* parent)
|
||||
: AbstractDialog(parent) {}
|
||||
EditItemDialog::EditItemDialog(QTableView* tableView, QWidget* parent)
|
||||
: AbstractDialog(parent)
|
||||
, m_tableView(tableView) {}
|
||||
|
||||
void EditItemDialog::createContent() {
|
||||
if (m_contentContainer) {
|
||||
@ -14,7 +15,18 @@ void EditItemDialog::createContent() {
|
||||
|
||||
setWindowTitle(tr("Edit item..."));
|
||||
|
||||
m_contentContainer = new ItemDetailMapper(this);
|
||||
m_detailMapper = new ItemDetailMapper(this);
|
||||
m_detailMapper->setModelMappings(m_tableView);
|
||||
m_contentContainer = m_detailMapper;
|
||||
|
||||
m_outerLayout->insertWidget(0, m_contentContainer);
|
||||
|
||||
void EditItemDialog::accept() {
|
||||
m_detailMapper->submit();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void EditItemDialog::reject() {
|
||||
m_detailMapper->revert();
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user