Using the new SpinBoxDelegate in int and double columns even if the cell is empty.

This commit is contained in:
2026-03-14 09:35:42 +01:00
parent c7b0e4f3e5
commit 24192df5d6
4 changed files with 108 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#include "model/metadata.h"
#include "model/tablemodel.h"
#include "widgets/controls/comboboxdelegate.h"
#include "widgets/controls/spinboxdelegate.h"
static QStandardPaths::StandardLocation standardLocation = QStandardPaths::HomeLocation;
static QString updateTextClean = "Do you want to update the application now?";
@ -343,6 +344,16 @@ void MainWindow::setupModelViews() {
// ui->tableView->setModel(m_tableModel.get());
m_proxyModel = m_core->getSortFilterModel();
// TODO iterate over INT_ROLES and DOUBLE_ROLES to set spinbox delegate
/// setting number delegates to combo boxes
SpinboxDelegate* spinboxDelegate = new SpinboxDelegate(this);
const int amountColumn = GET_COLUMN_FOR_ROLE(AmountRole);
ui->tableView->setItemDelegateForColumn(amountColumn, spinboxDelegate);
const int factorColumn = GET_COLUMN_FOR_ROLE(FactorRole);
ui->tableView->setItemDelegateForColumn(factorColumn, spinboxDelegate);
// TODO iterate over TYPE_ROLES to set combobox delegate
/// setting type delegates to combo boxes
const int typeColumn = GET_COLUMN_FOR_ROLE(TypeRole);
ComboboxDelegate* shareTypeDelegate = new ComboboxDelegate(TYPES, this);
ui->tableView->setItemDelegateForColumn(typeColumn, shareTypeDelegate);