code format
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#include "ui_piqt_iodevice_edit_dialog.h"
|
||||
#include "piqt_iodevice_edit_dialog.h"
|
||||
#include "piqt.h"
|
||||
|
||||
#include "picodeinfo.h"
|
||||
#include "piiodevice.h"
|
||||
#include "piqt.h"
|
||||
#include "ui_piqt_iodevice_edit_dialog.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
|
||||
|
||||
@@ -11,9 +13,10 @@ IODeviceEditDialog::IODeviceEditDialog(QWidget * parent): QDialog(parent) {
|
||||
ui->setupUi(this);
|
||||
PICodeInfo::EnumInfo * ei = PICodeInfo::enumsInfo->value("PIIODevice::DeviceMode");
|
||||
if (ei) {
|
||||
piForeachC (PICodeInfo::EnumeratorInfo & e, ei->members)
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2,39,0)
|
||||
ui->comboMode->addItem(PI2QString(e.name.toString() + " (" + PIString::fromNumber(e.value) + ")"), QVariant::fromValue<int>(e.value));
|
||||
piForeachC(PICodeInfo::EnumeratorInfo & e, ei->members)
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2, 39, 0)
|
||||
ui->comboMode->addItem(PI2QString(e.name.toString() + " (" + PIString::fromNumber(e.value) + ")"),
|
||||
QVariant::fromValue<int>(e.value));
|
||||
#else
|
||||
ui->comboMode->addItem(PI2QString(e.name + " (" + PIString::fromNumber(e.value) + ")"), QVariant::fromValue<int>(e.value));
|
||||
#endif
|
||||
@@ -21,9 +24,9 @@ IODeviceEditDialog::IODeviceEditDialog(QWidget * parent): QDialog(parent) {
|
||||
ui->comboMode->setCurrentIndex(ui->comboMode->count() - 1);
|
||||
ei = PICodeInfo::enumsInfo->value("PIIODevice::DeviceOption");
|
||||
if (ei) {
|
||||
piForeachC (PICodeInfo::EnumeratorInfo & e, ei->members) {
|
||||
piForeachC(PICodeInfo::EnumeratorInfo & e, ei->members) {
|
||||
QCheckBox * cb = new QCheckBox();
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2,39,0)
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2, 39, 0)
|
||||
cb->setText(PI2QString(e.name.toString() + " (" + PIString::fromNumber(e.value) + ")"));
|
||||
#else
|
||||
cb->setText(PI2QString(e.name + " (" + PIString::fromNumber(e.value) + ")"));
|
||||
@@ -33,23 +36,21 @@ IODeviceEditDialog::IODeviceEditDialog(QWidget * parent): QDialog(parent) {
|
||||
}
|
||||
}
|
||||
PIStringList pl = PIIODevice::availablePrefixes();
|
||||
piForeachC (PIString & p, pl) {
|
||||
piForeachC(PIString & p, pl) {
|
||||
ui->comboType->addItem(PI2QString(p));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IODeviceEditDialog::~IODeviceEditDialog() {
|
||||
}
|
||||
IODeviceEditDialog::~IODeviceEditDialog() {}
|
||||
|
||||
|
||||
int IODeviceEditDialog::getOptions() const {
|
||||
int ret = 0;
|
||||
for (int i = 0; i < ui->layoutOptions->count(); ++i) {
|
||||
QCheckBox * cb = qobject_cast<QCheckBox*>(ui->layoutOptions->itemAt(i)->widget());
|
||||
QCheckBox * cb = qobject_cast<QCheckBox *>(ui->layoutOptions->itemAt(i)->widget());
|
||||
if (!cb) continue;
|
||||
if (cb->isChecked())
|
||||
ret |= cb->property("__value").toInt();
|
||||
if (cb->isChecked()) ret |= cb->property("__value").toInt();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -57,7 +58,7 @@ int IODeviceEditDialog::getOptions() const {
|
||||
|
||||
void IODeviceEditDialog::setOptions(int o) {
|
||||
for (int i = 0; i < ui->layoutOptions->count(); ++i) {
|
||||
QCheckBox * cb = qobject_cast<QCheckBox*>(ui->layoutOptions->itemAt(i)->widget());
|
||||
QCheckBox * cb = qobject_cast<QCheckBox *>(ui->layoutOptions->itemAt(i)->widget());
|
||||
if (!cb) continue;
|
||||
int cbf = cb->property("__value").toInt();
|
||||
cb->setChecked((o & cbf) == cbf);
|
||||
@@ -67,7 +68,7 @@ void IODeviceEditDialog::setOptions(int o) {
|
||||
|
||||
void IODeviceEditDialog::on_comboType_currentIndexChanged(int index) {
|
||||
PIString prefix = Q2PIString(ui->comboType->currentText());
|
||||
auto * d = PIIODevice::createFromFullPath(prefix + "://");
|
||||
auto * d = PIIODevice::createFromFullPath(prefix + "://");
|
||||
if (d) {
|
||||
ps = PI2QPropertyStorage(d->constructVariant().get());
|
||||
ui->widgetProperties->setStorage(&ps);
|
||||
@@ -78,8 +79,7 @@ void IODeviceEditDialog::on_comboType_currentIndexChanged(int index) {
|
||||
|
||||
QAD::IODevice IODeviceEditDialog::getIODevice(const QAD::IODevice & d) {
|
||||
setValue(d);
|
||||
if (QDialog::exec() != QDialog::Accepted)
|
||||
return QAD::IODevice();
|
||||
if (QDialog::exec() != QDialog::Accepted) return QAD::IODevice();
|
||||
return value();
|
||||
}
|
||||
|
||||
@@ -87,10 +87,10 @@ QAD::IODevice IODeviceEditDialog::getIODevice(const QAD::IODevice & d) {
|
||||
QAD::IODevice IODeviceEditDialog::value() const {
|
||||
QAD::IODevice d;
|
||||
ui->widgetProperties->applyProperties();
|
||||
d.prefix = ui->comboType->currentText();
|
||||
d.mode = ui->comboMode->itemData(ui->comboMode->currentIndex()).toInt();
|
||||
d.prefix = ui->comboType->currentText();
|
||||
d.mode = ui->comboMode->itemData(ui->comboMode->currentIndex()).toInt();
|
||||
d.options = getOptions();
|
||||
d.props = ps;
|
||||
d.props = ps;
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user