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>
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ DeviceWidget::DeviceWidget(QWidget *parent) :
|
||||||
connect( &deviceView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(listActivated(const QModelIndex &)) );
|
connect( &deviceView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(listActivated(const QModelIndex &)) );
|
||||||
connect(&model, SIGNAL(showMessage(const QString &, const QString &, const QString &)), this, SIGNAL(showMessage(const QString &, const QString &, const QString &)));
|
connect(&model, SIGNAL(showMessage(const QString &, const QString &, const QString &)), this, SIGNAL(showMessage(const QString &, const QString &, const QString &)));
|
||||||
connect(&model, SIGNAL(eventTriggered(const QString &, const QString &)), this, SIGNAL(eventTriggered(const QString &, const QString &)));
|
connect(&model, SIGNAL(eventTriggered(const QString &, const QString &)), this, SIGNAL(eventTriggered(const QString &, const QString &)));
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
layout->addWidget(&deviceView);
|
layout->addWidget(&deviceView);
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -102,7 +115,7 @@ void DeviceWidget::addDevice() {
|
||||||
void DeviceWidget::addGroup() {
|
void DeviceWidget::addGroup() {
|
||||||
//Device *device = model.newDevice();
|
//Device *device = model.newDevice();
|
||||||
Device device(0, 0);
|
Device device(0, 0);
|
||||||
|
|
||||||
EditGroupDialog *dialog = new EditGroupDialog(&device, &model);
|
EditGroupDialog *dialog = new EditGroupDialog(&device, &model);
|
||||||
if (dialog->exec() == QDialog::Accepted) {
|
if (dialog->exec() == QDialog::Accepted) {
|
||||||
device.save();
|
device.save();
|
||||||
|
|
|
@ -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