use unique_ptr for model
This commit is contained in:
parent
fcf5f04539
commit
a130fa33c2
2 changed files with 6 additions and 10 deletions
|
@ -10,23 +10,17 @@ SellerDialog::SellerDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent,
|
|||
ui_.setupUi(this);
|
||||
ui_.editButton->setVisible(false);
|
||||
market_ = dynamic_cast<MainWindow*>(parent)->getMarketplace();
|
||||
SellerModel* model =
|
||||
new SellerModel(market_, ui_.tableView);
|
||||
ui_.tableView->setModel(model);
|
||||
model_ = std::make_unique<SellerModel>(market_, ui_.tableView);
|
||||
ui_.tableView->setModel(model_.get());
|
||||
ui_.tableView->setColumnHidden(0, true); // hide the uuid
|
||||
connect(ui_.newButton, &QPushButton::clicked, this, &SellerDialog::on_newButton_clicked);
|
||||
connect(ui_.deleteButton, &QPushButton::clicked, this, &SellerDialog::on_deleteButton_clicked);
|
||||
connect(model, &SellerModel::duplicateSellerNo, this,
|
||||
connect(model_.get(), &SellerModel::duplicateSellerNo, this,
|
||||
&SellerDialog::on_model_duplicateSellerNo);
|
||||
connect(ui_.tableView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&SellerDialog::onSellerViewSelectionChanged);
|
||||
}
|
||||
|
||||
SellerDialog::~SellerDialog()
|
||||
{
|
||||
delete ui_.tableView->model();
|
||||
}
|
||||
|
||||
void SellerDialog::on_newButton_clicked()
|
||||
{
|
||||
ui_.tableView->reset();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue