Fix Device Config and Wizard Interaction

.. when you add a device using the wizard from preferences
   it resets the model to reflect the changes made.

Fixes #785
This commit is contained in:
Mark Liversedge
2015-01-18 21:25:54 +00:00
parent c98cc0e3ea
commit 43d572edde
2 changed files with 15 additions and 1 deletions

View File

@@ -1084,6 +1084,7 @@ DevicePage::DevicePage(QWidget *parent, Context *context) : QWidget(parent), con
connect(addButton, SIGNAL(clicked()), this, SLOT(devaddClicked()));
connect(delButton, SIGNAL(clicked()), this, SLOT(devdelClicked()));
connect(context, SIGNAL(configChanged(qint32)), deviceListModel, SLOT(doReset()));
}
qint32
@@ -1164,6 +1165,15 @@ deviceModel::deviceModel(QObject *parent) : QAbstractTableModel(parent)
Configuration = all.getList();
}
void
deviceModel::doReset()
{
beginResetModel();
DeviceConfigurations all;
Configuration = all.getList();
endResetModel();
}
int
deviceModel::rowCount(const QModelIndex &parent) const
{

View File

@@ -235,8 +235,12 @@ class deviceModel : public QAbstractTableModel
bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex());
bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex());
QList<DeviceConfiguration> Configuration; // the actual data
public slots:
// config changed by wizard so reset
void doReset();
};
class DevicePage : public QWidget