17#ifndef NONEMPTYDELEGATE_H
18#define NONEMPTYDELEGATE_H
22#include <QStyledItemDelegate>
44 void setModelData(QWidget* editor, QAbstractItemModel* model,
const QModelIndex& index)
const override {
45 QLineEdit* lineEdit = qobject_cast<QLineEdit*>(editor);
46 if (lineEdit && lineEdit->text().trimmed().isEmpty()) {
47 if (parent() !=
nullptr) {
48 NeTrainSim* netP = qobject_cast<NeTrainSim*>(parent());
54 QString value = lineEdit->text().trimmed();
56 value.toDouble(&isNumeric);
59 if (parent() !=
nullptr) {
60 NeTrainSim* netP = qobject_cast<NeTrainSim*>(parent());
66 QStyledItemDelegate::setModelData(editor, model, index);
A network train simulation GUI.
Definition netrainsimmainwindow.h:40
void showWarning(QString text)
Displays a warning message with the given text.
Definition netrainsimmainwindow.cpp:1718
The NonEmptyDelegate class provides functionality to ensure that table cells are not empty.
Definition nonemptydelegate.h:28
NonEmptyDelegate(QObject *parent=nullptr)
Constructs a NonEmptyDelegate object with the given parent.
Definition nonemptydelegate.h:36
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Sets the model data based on the data of the editor widget.
Definition nonemptydelegate.h:44