tell views to update when a device changes state
This commit is contained in:
parent
75598b4359
commit
8b5da1d1ca
|
@ -8,6 +8,12 @@ WidgetModel::WidgetModel(QObject *parent)
|
|||
}
|
||||
|
||||
|
||||
WidgetModel::~WidgetModel() {
|
||||
for(auto &wdgt: widgets_)
|
||||
disconnect(wdgt.get(), nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
|
||||
QVariant WidgetModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
||||
|
@ -127,5 +133,10 @@ void WidgetModel::rescanPorts()
|
|||
beginInsertRows(QModelIndex(), widgets_.size(), widgets_.size()+newWidgets.size()-1);
|
||||
widgets_.append(newWidgets);
|
||||
endInsertRows();
|
||||
for(auto &wdgt: newWidgets)
|
||||
connect(wdgt.get(), &DmxWidget::connectedChanged, this, [this](){
|
||||
// refresh the whole view. Could be optimized by looking for this widget in the rows.
|
||||
emit dataChanged(createIndex(0,0), createIndex(rowCount(),columnCount()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ class WidgetModel : public QAbstractItemModel
|
|||
|
||||
public:
|
||||
explicit WidgetModel(QObject *parent = nullptr);
|
||||
virtual ~WidgetModel();
|
||||
|
||||
// Header:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
|
Loading…
Reference in New Issue
Block a user