Set the widget enabled false and emit an error if we cannot connect to the service
This commit is contained in:
parent
70194457a9
commit
dec6018464
2 changed files with 16 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -68,6 +69,14 @@ DeviceWidget::DeviceWidget(QWidget *parent) :
|
||||||
buttonLayout->addStretch();
|
buttonLayout->addStretch();
|
||||||
|
|
||||||
layout->addLayout( buttonLayout );
|
layout->addLayout( buttonLayout );
|
||||||
|
|
||||||
|
if (model.haveError()) {
|
||||||
|
//We emit the signal in the next "event loop".
|
||||||
|
//This to allow the signals to be connected from our parent object
|
||||||
|
QTimer::singleShot(0, this, SLOT(emitError()));
|
||||||
|
this->setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceWidget::~DeviceWidget()
|
DeviceWidget::~DeviceWidget()
|
||||||
|
@ -85,6 +94,10 @@ void DeviceWidget::changeEvent(QEvent *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceWidget::emitError() {
|
||||||
|
emit showMessage("", model.errorString(), "");
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceWidget::addDevice() {
|
void DeviceWidget::addDevice() {
|
||||||
Device device(0, 0);
|
Device device(0, 0);
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ private slots:
|
||||||
void addGroup();
|
void addGroup();
|
||||||
void deleteDevice();
|
void deleteDevice();
|
||||||
void editDevice();
|
void editDevice();
|
||||||
|
void emitError();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DeviceModel model;
|
DeviceModel model;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue