git-svn-id: svn://db.shs.com.ru/libs@146 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
#include <QSqlRecord>
|
||||
#include <QCheckBox>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
@@ -24,6 +25,15 @@ ConnectionEdit::ConnectionEdit(QWidget * parent): QDialog(parent) {
|
||||
ui->comboMode->addItem(PI2QString(e.name + " (" + PIString::fromNumber(e.value) + ")"), QVariant::fromValue<int>(e.value));
|
||||
}
|
||||
ui->comboMode->setCurrentIndex(ui->comboMode->count() - 1);
|
||||
ei = PICodeInfo::enumsInfo->value("PIIODevice::DeviceOption");
|
||||
if (ei) {
|
||||
piForeachC (PICodeInfo::EnumeratorInfo & e, ei->members) {
|
||||
QCheckBox * cb = new QCheckBox();
|
||||
cb->setText(PI2QString(e.name + " (" + PIString::fromNumber(e.value) + ")"));
|
||||
cb->setProperty("__value", e.value);
|
||||
ui->layoutOptions->addWidget(cb);
|
||||
}
|
||||
}
|
||||
ei = PICodeInfo::enumsInfo->value("PIPacketExtractor::SplitMode");
|
||||
if (ei) {
|
||||
piForeachC (PICodeInfo::EnumeratorInfo & e, ei->members)
|
||||
@@ -171,6 +181,7 @@ void ConnectionEdit::selectionChanged() {
|
||||
ui->lineDevice->setText(di->name());
|
||||
ui->linePath->setEditText(di->path());
|
||||
ui->spinDeviceDT->setValue(di->disconnectTimeout());
|
||||
setOptions(di->options());
|
||||
}
|
||||
if (type == __CV_Filter) {
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
@@ -219,6 +230,7 @@ void ConnectionEdit::applyDevice(DeviceItem * b) {
|
||||
}
|
||||
b->setName(n);
|
||||
b->setMode(PIIODevice::DeviceMode(ui->comboMode->itemData(ui->comboMode->currentIndex()).toInt()));
|
||||
b->setOptions(PIIODevice::DeviceOptions(getOptions()));
|
||||
b->setPath(ui->linePath->currentText());
|
||||
b->setDisconnectTimeout(ui->spinDeviceDT->value());
|
||||
recreateConnection();
|
||||
@@ -233,6 +245,29 @@ void ConnectionEdit::applySender(SenderItem * b) {
|
||||
}
|
||||
|
||||
|
||||
int ConnectionEdit::getOptions() const {
|
||||
int ret(0);
|
||||
for (int i = 0; i < ui->layoutOptions->count(); ++i) {
|
||||
QCheckBox * cb = qobject_cast<QCheckBox*>(ui->layoutOptions->itemAt(i)->widget());
|
||||
if (!cb) continue;
|
||||
if (cb->isChecked())
|
||||
ret |= cb->property("__value").toInt();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::setOptions(int o) {
|
||||
for (int i = 0; i < ui->layoutOptions->count(); ++i) {
|
||||
QCheckBox * cb = qobject_cast<QCheckBox*>(ui->layoutOptions->itemAt(i)->widget());
|
||||
if (!cb) continue;
|
||||
int cbf = cb->property("__value").toInt();
|
||||
//qDebug() << cbf;
|
||||
cb->setChecked((o & cbf) == cbf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::recreateConnection() {
|
||||
//qDebug() << "recreate";
|
||||
if (loading) return;
|
||||
@@ -247,6 +282,7 @@ void ConnectionEdit::recreateConnection() {
|
||||
//qDebug() << di->path();
|
||||
PIIODevice * dev = conn->addDevice(Q2PIString(di->path()), di->mode());
|
||||
if (!dev) continue;
|
||||
dev->setOptions(di->options());
|
||||
conn->setDeviceName(dev, Q2PIString(di->name()));
|
||||
PIDiagnostics * diag = conn->diagnostic(dev);
|
||||
if (diag) diag->setDisconnectTimeout(di->disconnectTimeout());
|
||||
|
||||
Reference in New Issue
Block a user