moved to shstk
This commit is contained in:
9
libs/piqt_widgets/CMakeLists.txt
Normal file
9
libs/piqt_widgets/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
include(PIPMacros)
|
||||
pip_code_model(CCM "${ROOT_DIR}/pip/libs/main/io_devices/piiodevice.h" "${ROOT_DIR}/pip/libs/main/io_utils/pipacketextractor.h" OPTIONS "-DPIP_EXPORT" "-Es")
|
||||
piqt_library(piqt_utils "Gui" "qad_utils;qad_widgets;qad_blockview;piqt" ${CCM})
|
||||
|
||||
foreach(_v ${_QT_VERSIONS_})
|
||||
if (LOCAL_FOUND${_v})
|
||||
add_dependencies(piqt_utils${_v} pip_cmg)
|
||||
endif()
|
||||
endforeach()
|
||||
493
libs/piqt_widgets/piqt_connection_edit.cpp
Normal file
493
libs/piqt_widgets/piqt_connection_edit.cpp
Normal file
@@ -0,0 +1,493 @@
|
||||
#include "ui_piqt_connection_edit.h"
|
||||
#include "piqt_connection_edit.h"
|
||||
#include "piqt_connection_view.h"
|
||||
#include "piqt_highlighter.h"
|
||||
#include "piqt.h"
|
||||
#include "picodeinfo.h"
|
||||
#include <QCheckBox>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
ConnectionEdit::ConnectionEdit(QWidget * parent): QDialog(parent) {
|
||||
ui = new Ui::ConnectionEdit();
|
||||
ui->setupUi(this);
|
||||
new ConfigHighlighter(ui->codeEdit->document());
|
||||
loading = false;
|
||||
connect(ui->blockView, SIGNAL(schemeAction(BlockItemBase::Action,QList<QGraphicsItem*>)), this, SLOT(recreateRequest()));
|
||||
connect(ui->blockView->scene(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
||||
conn = 0;
|
||||
PICodeInfo::EnumInfo * ei = PICodeInfo::enumsInfo->value("PIIODevice::DeviceMode");
|
||||
if (ei) {
|
||||
piForeachC (PICodeInfo::EnumeratorInfo & e, ei->members)
|
||||
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)
|
||||
ui->comboSplit->addItem(PI2QString(e.name + " (" + PIString::fromNumber(e.value) + ")"), QVariant::fromValue<int>(e.value));
|
||||
}
|
||||
udevicenum = 0;
|
||||
}
|
||||
|
||||
|
||||
ConnectionEdit::~ConnectionEdit() {
|
||||
if (conn) {
|
||||
conn->stop();
|
||||
delete conn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::accept() {
|
||||
//bool ok = false;
|
||||
QList<BlockItem * > bl = ui->blockView->allDevices();
|
||||
foreach (BlockItem * i, bl)
|
||||
foreach (BlockItem * j, bl)
|
||||
if (i != j)
|
||||
if (((DeviceItem*)i)->name() == ((DeviceItem*)j)->name()) {
|
||||
QMessageBox::critical(this, windowTitle() + " - " + tr("error") + "!", tr("Equal devices names: \"%1\"!").arg(((DeviceItem*)i)->name()));
|
||||
return;
|
||||
}
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
|
||||
QString ConnectionEdit::configuration() const {
|
||||
if (!conn) return QString();
|
||||
return PI2QString(conn->makeConfig());
|
||||
}
|
||||
|
||||
|
||||
QByteArray ConnectionEdit::model() const {
|
||||
QByteArray ret;
|
||||
QDataStream s(&ret, QIODevice::ReadWrite);
|
||||
QString cn = PI2QString(conn ? conn->name() : PIString());
|
||||
s << cn;
|
||||
QList<BlockBusItem*> busl = ui->blockView->buses();
|
||||
s << busl.size();
|
||||
foreach (BlockBusItem * b, busl)
|
||||
s << b->save();
|
||||
QList<BlockItem*> blockl = ui->blockView->blocks();
|
||||
s << blockl.size();
|
||||
foreach (BlockItem * b, blockl) {
|
||||
int type = b->propertyByName("__type").value.toInt();
|
||||
s << type;
|
||||
switch (type) {
|
||||
case __CV_Device:
|
||||
case __CV_Filter:
|
||||
case __CV_Sender:
|
||||
s << b->save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
QString ConnectionEdit::name() const {
|
||||
if (!conn) return QString();
|
||||
return PI2QString(conn->name());
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::setName(const QString & name) {
|
||||
ui->lineName->setText(name);
|
||||
recreateConnection();
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::addDevice(const QString & name, const QString & path) {
|
||||
ui->blockView->addDevice(name, path);
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::setModel(const QByteArray & m) {
|
||||
loading = true;
|
||||
ui->blockView->removeAll();
|
||||
QDataStream s(m);
|
||||
QString cn;
|
||||
s >> cn;
|
||||
if (conn) delete conn;
|
||||
conn = new PIConnection(Q2PIString(cn));
|
||||
ui->lineName->setText(cn);
|
||||
int sz;
|
||||
s >> sz;
|
||||
for (int i = 0; i < sz; ++i) {
|
||||
BlockBusItem * b = new BlockBusItem();
|
||||
QByteArray ba; s >> ba; b->load(ba);
|
||||
ui->blockView->addItem(b);
|
||||
}
|
||||
s >> sz;
|
||||
for (int i = 0; i < sz; ++i) {
|
||||
int type(0);
|
||||
BlockItem * b(0);
|
||||
QByteArray ba;
|
||||
s >> type;
|
||||
switch (type) {
|
||||
case __CV_Device:
|
||||
b = new DeviceItem();
|
||||
s >> ba; b->load(ba);
|
||||
if (!b->isPropertyExists("bufferSize"))
|
||||
((DeviceItem*)b)->setBufferSize(4096);
|
||||
((DeviceItem*)b)->rename();
|
||||
break;
|
||||
case __CV_Filter:
|
||||
b = new FilterItem();
|
||||
s >> ba; b->load(ba);
|
||||
if (!b->isPropertyExists("bufferSize"))
|
||||
((FilterItem*)b)->setBufferSize(65536);
|
||||
((FilterItem*)b)->rename();
|
||||
break;
|
||||
case __CV_Sender:
|
||||
b = new SenderItem();
|
||||
s >> ba; b->load(ba);
|
||||
((SenderItem*)b)->rename();
|
||||
break;
|
||||
}
|
||||
if (b)
|
||||
ui->blockView->addItem(b);
|
||||
}
|
||||
ui->blockView->reconnectAll();
|
||||
loading = false;
|
||||
recreateConnection();
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::selectionChanged() {
|
||||
QList<QGraphicsItem*> si = ui->blockView->scene()->selectedItems();
|
||||
ui->buttonRemove->setEnabled(!si.isEmpty());
|
||||
ui->buttonDeviceModify->setEnabled(false);
|
||||
ui->buttonFilterModify->setEnabled(false);
|
||||
ui->buttonSenderModify->setEnabled(false);
|
||||
if (si.size() != 1) return;
|
||||
BlockItem * b = qgraphicsitem_cast<BlockItem*>(si[0]);
|
||||
if (!b) return;
|
||||
int type = b->propertyByName("__type").value.toInt();
|
||||
if (type == __CV_Device) {
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
DeviceItem * di = (DeviceItem*)b;
|
||||
ui->buttonDeviceModify->setEnabled(true);
|
||||
for (int i = 0; i < ui->comboMode->count(); ++i)
|
||||
if (ui->comboMode->itemData(i).toInt() == di->mode()) {
|
||||
ui->comboMode->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
ui->lineDevice->setText(di->name());
|
||||
ui->linePath->setEditText(di->path());
|
||||
ui->spinDeviceDT->setValue(di->disconnectTimeout());
|
||||
ui->spinDeviceBS->setValue(di->bufferSize());
|
||||
setOptions(di->options());
|
||||
}
|
||||
if (type == __CV_Filter) {
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
FilterItem * fi = (FilterItem*)b;
|
||||
ui->buttonFilterModify->setEnabled(true);
|
||||
for (int i = 0; i < ui->comboSplit->count(); ++i)
|
||||
if (ui->comboSplit->itemData(i).toInt() == fi->mode()) {
|
||||
ui->comboSplit->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
ui->lineFilter->setText(fi->name());
|
||||
ui->lineHeader->setText(fi->header());
|
||||
ui->lineFooter->setText(fi->footer());
|
||||
ui->spinTimeout->setValue(fi->timeout());
|
||||
ui->spinSize->setValue(fi->packetSize());
|
||||
ui->spinFilterDT->setValue(fi->disconnectTimeout());
|
||||
ui->spinFilterBS->setValue(fi->bufferSize());
|
||||
}
|
||||
if (type == __CV_Sender) {
|
||||
ui->tabWidget->setCurrentIndex(2);
|
||||
SenderItem * si = (SenderItem*)b;
|
||||
ui->buttonSenderModify->setEnabled(true);
|
||||
ui->lineSender->setText(si->name());
|
||||
ui->lineData->setText(si->data());
|
||||
ui->spinFrequency->setValue(si->frequency());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::applyFilter(FilterItem * b) {
|
||||
b->setName(ui->lineFilter->text());
|
||||
b->setMode(PIPacketExtractor::SplitMode(ui->comboSplit->itemData(ui->comboSplit->currentIndex()).toInt()));
|
||||
b->setHeader(ui->lineHeader->text());
|
||||
b->setFooter(ui->lineFooter->text());
|
||||
b->setTimeout(ui->spinTimeout->value());
|
||||
b->setPacketSize(ui->spinSize->value());
|
||||
b->setDisconnectTimeout(ui->spinFilterDT->value());
|
||||
b->setBufferSize(ui->spinFilterBS->value());
|
||||
recreateConnection();
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::applyDevice(DeviceItem * b) {
|
||||
QString n = ui->lineDevice->text();
|
||||
if (n.isEmpty()) {
|
||||
n = "device" + QString::number(udevicenum);
|
||||
}
|
||||
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());
|
||||
b->setBufferSize(ui->spinDeviceBS->value());
|
||||
recreateConnection();
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::applySender(SenderItem * b) {
|
||||
b->setName(ui->lineSender->text());
|
||||
b->setData(ui->lineData->text());
|
||||
b->setFrequency(ui->spinFrequency->value());
|
||||
recreateConnection();
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
ui->blockView->reconnectAll();
|
||||
if (conn) delete conn;
|
||||
PIString cn = Q2PIString(ui->lineName->text());
|
||||
if (cn.isEmpty()) conn = new PIConnection();
|
||||
else conn = new PIConnection(cn);
|
||||
QList<BlockItem*> devs = ui->blockView->allDevices();
|
||||
foreach (BlockItem * b, devs) {
|
||||
DeviceItem * di = (DeviceItem*)b;
|
||||
//qDebug() << di->path();
|
||||
PIIODevice * dev = conn->addDevice(Q2PIString(di->path()), di->mode());
|
||||
if (!dev) continue;
|
||||
dev->setOptions(di->options());
|
||||
dev->setThreadedReadBufferSize(di->bufferSize());
|
||||
conn->setDeviceName(dev, Q2PIString(di->name()));
|
||||
PIDiagnostics * diag = conn->diagnostic(dev);
|
||||
if (diag) diag->setDisconnectTimeout(di->disconnectTimeout());
|
||||
}
|
||||
foreach (BlockItem * b, devs) {
|
||||
DeviceItem * di = (DeviceItem*)b;
|
||||
PIIODevice * dev = conn->deviceByName(Q2PIString(di->name()));
|
||||
if (!dev) continue;
|
||||
BlockItemPin * p = b->pinByText("read");
|
||||
if (!p) continue;
|
||||
QList<BlockBusItem*> buses = p->connectedBuses(), nbuses;
|
||||
QSet<BlockBusItem*> pbuses;
|
||||
while (!buses.isEmpty()) {
|
||||
nbuses.clear();
|
||||
foreach (BlockBusItem * bus, buses) {
|
||||
QList<BlockItem*> cb = bus->connectedBlocks();
|
||||
if (cb.size() != 2) continue;
|
||||
FilterItem * fi_t(0);
|
||||
BlockItem * bi_f(0);
|
||||
if (cb[0]->pinAtBus(bus)->text() == "in") {
|
||||
fi_t = (FilterItem*)(cb[0]);
|
||||
bi_f = (cb[1]);
|
||||
} else if (cb[1]->pinAtBus(bus)->text() == "in") {
|
||||
fi_t = (FilterItem*)(cb[1]);
|
||||
bi_f = (cb[0]);
|
||||
}
|
||||
if (!fi_t || !bi_f) continue;
|
||||
PIString name_from;
|
||||
int type = bi_f->propertyByName("__type").value.toInt();
|
||||
if (type == __CV_Device) name_from = Q2PIString(((DeviceItem*)bi_f)->name());
|
||||
if (type == __CV_Filter) name_from = Q2PIString(((FilterItem*)bi_f)->name());
|
||||
if (name_from.isEmpty()) continue;
|
||||
PIPacketExtractor * pe = conn->addFilter(Q2PIString(fi_t->name()),conn->deviceByName(name_from), fi_t->mode());
|
||||
if (!pe) continue;
|
||||
pe->setBufferSize(fi_t->bufferSize());
|
||||
pe->setHeader(PIByteArray::fromUserInput(Q2PIString(fi_t->header())));
|
||||
pe->setFooter(PIByteArray::fromUserInput(Q2PIString(fi_t->footer())));
|
||||
pe->setTimeout(fi_t->timeout());
|
||||
pe->setPacketSize(fi_t->packetSize());
|
||||
pe->setPayloadSize(fi_t->packetSize());
|
||||
PIDiagnostics * diag = conn->diagnostic(pe);
|
||||
if (diag) diag->setDisconnectTimeout(fi_t->disconnectTimeout());
|
||||
QList<BlockBusItem*> nb = fi_t->pinByText("out")->connectedBuses();
|
||||
foreach (BlockBusItem * b_, nb)
|
||||
if (!pbuses.contains(b_)) {
|
||||
pbuses << b_;
|
||||
nbuses << b_;
|
||||
}
|
||||
}
|
||||
buses = nbuses;
|
||||
}
|
||||
}
|
||||
foreach (BlockItem * b, devs) {
|
||||
BlockItemPin * p = b->pinByText("write");
|
||||
if (!p) continue;
|
||||
QList<BlockBusItem*> buses = p->connectedBuses();
|
||||
foreach (BlockBusItem * bus, buses) {
|
||||
QList<BlockItem*> cb = bus->connectedBlocks();
|
||||
if (cb.size() != 2) continue;
|
||||
BlockItem * bi_f(0);
|
||||
DeviceItem * di_t(0);
|
||||
if (cb[0]->pinAtBus(bus)->text() == "write") {
|
||||
di_t = (DeviceItem*)(cb[0]);
|
||||
bi_f = (cb[1]);
|
||||
} else if (cb[1]->pinAtBus(bus)->text() == "write") {
|
||||
di_t = (DeviceItem*)(cb[1]);
|
||||
bi_f = (cb[0]);
|
||||
}
|
||||
if (!bi_f || !di_t) continue;
|
||||
QString name_from;
|
||||
int type = bi_f->propertyByName("__type").value.toInt();
|
||||
if (type == __CV_Sender) {
|
||||
SenderItem * si = ((SenderItem*)bi_f);
|
||||
si->name();
|
||||
conn->addSender(Q2PIString(si->name()), Q2PIString(di_t->path()), si->frequency());
|
||||
if (!si->data().isEmpty())
|
||||
conn->setSenderFixedData(Q2PIString(si->name()), PIByteArray::fromUserInput(Q2PIString(si->data())));
|
||||
} else {
|
||||
if (type == __CV_Device) name_from = ((DeviceItem*)bi_f)->name();
|
||||
if (type == __CV_Filter) name_from = ((FilterItem*)bi_f)->name();
|
||||
if (name_from.isEmpty()) continue;
|
||||
conn->addChannel(Q2PIString(name_from), Q2PIString(di_t->name()));
|
||||
}
|
||||
}
|
||||
}
|
||||
ui->codeEdit->setText(PI2QString(conn->makeConfig()));
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::on_buttonRemove_clicked() {
|
||||
ui->blockView->removeSelected();
|
||||
recreateConnection();
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::on_buttonClear_clicked() {
|
||||
ui->blockView->removeAll();
|
||||
recreateConnection();
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::on_buttonFilterAdd_clicked() {
|
||||
if (!conn) return;
|
||||
applyFilter(ui->blockView->addFilter(ui->lineFilter->text()));
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::on_buttonFilterModify_clicked() {
|
||||
QList<QGraphicsItem*> si = ui->blockView->scene()->selectedItems();
|
||||
if (si.isEmpty()) return;
|
||||
if (!qgraphicsitem_cast<BlockItem*>(si[0])) return;
|
||||
if (qgraphicsitem_cast<BlockItem*>(si[0])->propertyByName("__type").value.toInt() != __CV_Filter)
|
||||
return;
|
||||
applyFilter(qgraphicsitem_cast<FilterItem*>(si[0]));
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::on_buttonDeviceAdd_clicked() {
|
||||
if (!conn) return;
|
||||
QString n = ui->lineDevice->text();
|
||||
if (n.isEmpty()) {
|
||||
udevicenum++;
|
||||
n = "device" + QString::number(udevicenum);
|
||||
}
|
||||
QString p = ui->linePath->currentText();
|
||||
if (ui->linePath->findText(p) < 0) ui->linePath->addItem(p);
|
||||
qDebug() << "add:" << n;
|
||||
applyDevice(ui->blockView->addDevice(n, ui->linePath->currentText()));
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::on_buttonDeviceModify_clicked() {
|
||||
QList<QGraphicsItem*> si = ui->blockView->scene()->selectedItems();
|
||||
if (si.isEmpty()) return;
|
||||
if (!qgraphicsitem_cast<BlockItem*>(si[0])) return;
|
||||
if (qgraphicsitem_cast<BlockItem*>(si[0])->propertyByName("__type").value.toInt() != __CV_Device)
|
||||
return;
|
||||
applyDevice(qgraphicsitem_cast<DeviceItem*>(si[0]));
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::on_buttonSenderAdd_clicked() {
|
||||
if (!conn) return;
|
||||
applySender(ui->blockView->addSender(ui->lineSender->text()));
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::on_buttonSenderModify_clicked() {
|
||||
QList<QGraphicsItem*> si = ui->blockView->scene()->selectedItems();
|
||||
if (si.isEmpty()) return;
|
||||
if (!qgraphicsitem_cast<BlockItem*>(si[0])) return;
|
||||
if (qgraphicsitem_cast<BlockItem*>(si[0])->propertyByName("__type").value.toInt() != __CV_Sender)
|
||||
return;
|
||||
applySender(qgraphicsitem_cast<SenderItem*>(si[0]));
|
||||
}
|
||||
|
||||
|
||||
void ConnectionEdit::on_comboSplit_currentIndexChanged(int index) {
|
||||
int mode = ui->comboSplit->itemData(index).toInt();
|
||||
switch (mode) {
|
||||
case PIPacketExtractor::None:
|
||||
ui->widgetHeader->setEnabled(false);
|
||||
ui->widgetFooter->setEnabled(false);
|
||||
ui->widgetTimeout->setEnabled(false);
|
||||
ui->widgetSize->setEnabled(false);
|
||||
break;
|
||||
case PIPacketExtractor::Header:
|
||||
ui->widgetHeader->setEnabled(true);
|
||||
ui->widgetFooter->setEnabled(false);
|
||||
ui->widgetTimeout->setEnabled(false);
|
||||
ui->widgetSize->setEnabled(true);
|
||||
break;
|
||||
case PIPacketExtractor::Footer:
|
||||
ui->widgetHeader->setEnabled(false);
|
||||
ui->widgetFooter->setEnabled(true);
|
||||
ui->widgetTimeout->setEnabled(false);
|
||||
ui->widgetSize->setEnabled(true);
|
||||
break;
|
||||
case PIPacketExtractor::HeaderAndFooter:
|
||||
ui->widgetHeader->setEnabled(true);
|
||||
ui->widgetFooter->setEnabled(true);
|
||||
ui->widgetTimeout->setEnabled(false);
|
||||
ui->widgetSize->setEnabled(false);
|
||||
break;
|
||||
case PIPacketExtractor::Timeout:
|
||||
ui->widgetHeader->setEnabled(false);
|
||||
ui->widgetFooter->setEnabled(false);
|
||||
ui->widgetTimeout->setEnabled(true);
|
||||
ui->widgetSize->setEnabled(false);
|
||||
break;
|
||||
case PIPacketExtractor::Size:
|
||||
ui->widgetHeader->setEnabled(false);
|
||||
ui->widgetFooter->setEnabled(false);
|
||||
ui->widgetTimeout->setEnabled(false);
|
||||
ui->widgetSize->setEnabled(true);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
82
libs/piqt_widgets/piqt_connection_edit.h
Normal file
82
libs/piqt_widgets/piqt_connection_edit.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
PIQt Utils - Qt utilites for PIP
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONNECTION_EDIT_H
|
||||
#define CONNECTION_EDIT_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "piconnection.h"
|
||||
#include "piqt_utils_export.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class ConnectionEdit;
|
||||
}
|
||||
|
||||
class FilterItem;
|
||||
class DeviceItem;
|
||||
class SenderItem;
|
||||
|
||||
class PIQT_UTILS_EXPORT ConnectionEdit: public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConnectionEdit(QWidget * parent = 0);
|
||||
~ConnectionEdit();
|
||||
|
||||
QString configuration() const;
|
||||
QByteArray model() const;
|
||||
QString name() const;
|
||||
|
||||
void setName(const QString & name);
|
||||
void addDevice(const QString & name, const QString & path);
|
||||
void setModel(const QByteArray & m);
|
||||
|
||||
private:
|
||||
void accept();
|
||||
void keyPressEvent(QKeyEvent *) {}
|
||||
void applyFilter(FilterItem * b);
|
||||
void applyDevice(DeviceItem * b);
|
||||
void applySender(SenderItem * b);
|
||||
int getOptions() const;
|
||||
void setOptions(int o);
|
||||
|
||||
Ui::ConnectionEdit * ui;
|
||||
PIConnection * conn;
|
||||
bool loading;
|
||||
int udevicenum;
|
||||
|
||||
private slots:
|
||||
void recreateRequest() {if (!loading) QMetaObject::invokeMethod(this, "recreateConnection", Qt::QueuedConnection);}
|
||||
void on_buttonRemove_clicked();
|
||||
void on_buttonClear_clicked();
|
||||
void on_buttonFilterAdd_clicked();
|
||||
void on_buttonFilterModify_clicked();
|
||||
void on_buttonDeviceAdd_clicked();
|
||||
void on_buttonDeviceModify_clicked();
|
||||
void on_buttonSenderAdd_clicked();
|
||||
void on_buttonSenderModify_clicked();
|
||||
void on_comboSplit_currentIndexChanged(int index);
|
||||
void selectionChanged();
|
||||
|
||||
public slots:
|
||||
void recreateConnection();
|
||||
|
||||
};
|
||||
|
||||
#endif // CONNECTION_EDIT_H
|
||||
942
libs/piqt_widgets/piqt_connection_edit.ui
Normal file
942
libs/piqt_widgets/piqt_connection_edit.ui
Normal file
@@ -0,0 +1,942 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConnectionEdit</class>
|
||||
<widget class="QDialog" name="ConnectionEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>794</width>
|
||||
<height>799</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Connection editor</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineName"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Device</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelFilter_4">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="CLineEdit" name="lineDevice"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelFilter_11">
|
||||
<property name="text">
|
||||
<string>Path:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="EComboBox" name="linePath">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>eth://UDP:127.0.0.1:12345:127.0.0.1:12346</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>eth://TCP:127.0.0.1:16666</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>eth://UDP:192.168.0.5:16666:192.168.0.6:16667:mcast:234.0.2.1:mcast:234.0.2.2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>file://./text.txt</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>binlog://./logs/:mylog_:1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>ser:///dev/ttyUSB0:9600:8:N:1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>ser://COM32:115200:8:N:1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>usb://0bb4:0c86:1:1:2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelFilter_12">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboMode"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelFilter_14">
|
||||
<property name="text">
|
||||
<string>Options:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QVBoxLayout" name="layoutOptions">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter_13">
|
||||
<property name="text">
|
||||
<string>Disconnect timeout:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="spinDeviceDT">
|
||||
<property name="suffix">
|
||||
<string> ms</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>3.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter_15">
|
||||
<property name="text">
|
||||
<string>Buffer size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinDeviceBS">
|
||||
<property name="suffix">
|
||||
<string> b</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_18">
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonDeviceAdd">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qad/libs/application/qad_application.qrc">
|
||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonDeviceModify">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Modify</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qad/libs/application/qad_application.qrc">
|
||||
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Filter</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="CLineEdit" name="lineFilter"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboSplit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Parameters</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetHeader" native="true">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter_2">
|
||||
<property name="text">
|
||||
<string>Header:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="CLineEdit" name="lineHeader"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetFooter" native="true">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter_3">
|
||||
<property name="text">
|
||||
<string>Footer:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="CLineEdit" name="lineFooter"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetTimeout" native="true">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter_7">
|
||||
<property name="text">
|
||||
<string>Timeout:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="spinTimeout">
|
||||
<property name="suffix">
|
||||
<string> ms</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>99999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>10.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetSize" native="true">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter_8">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinSize">
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>8</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetDT" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter_9">
|
||||
<property name="text">
|
||||
<string>Disconnect timeout:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="spinFilterDT">
|
||||
<property name="suffix">
|
||||
<string> ms</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>3.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetSize_2" native="true">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>17</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter_17">
|
||||
<property name="text">
|
||||
<string>Buffer size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinFilterBS">
|
||||
<property name="suffix">
|
||||
<string> b</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>65536</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonFilterAdd">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qad/libs/application/qad_application.qrc">
|
||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonFilterModify">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Modify</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/icons/document-save-.png</normaloff>:/icons/document-save-.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
<string>Sender</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelFilter_5">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="CLineEdit" name="lineSender"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelFilter_16">
|
||||
<property name="text">
|
||||
<string>Frequency:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinFrequency">
|
||||
<property name="suffix">
|
||||
<string> Hz</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>10.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelFilter_6">
|
||||
<property name="text">
|
||||
<string>Data:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="CLineEdit" name="lineData"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>77</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_19">
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonSenderAdd">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qad/libs/application/qad_application.qrc">
|
||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonSenderModify">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Modify</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/icons/document-save-.png</normaloff>:/icons/document-save-.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonRemove">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qad/libs/application/qad_application.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonClear">
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qad/libs/application/qad_application.qrc">
|
||||
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ConnectionView" name="blockView">
|
||||
<property name="traceConsiderBuses">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="pinMulticonnect" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="miniMap" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QCodeEdit" name="codeEdit"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlockView</class>
|
||||
<extends>QGraphicsView</extends>
|
||||
<header>blockview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>clineedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>EComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>ecombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QCodeEdit</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qcodeedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ConnectionView</class>
|
||||
<extends>BlockView</extends>
|
||||
<header>piqt_connection_view.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../qad/libs/application/qad_application.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ConnectionEdit</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>442</x>
|
||||
<y>738</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>413</x>
|
||||
<y>426</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ConnectionEdit</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>669</x>
|
||||
<y>738</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>643</x>
|
||||
<y>428</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>recreateConnection()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
204
libs/piqt_widgets/piqt_connection_view.cpp
Normal file
204
libs/piqt_widgets/piqt_connection_view.cpp
Normal file
@@ -0,0 +1,204 @@
|
||||
#include "piqt_connection_view.h"
|
||||
#include "picodeinfo.h"
|
||||
#include "piqt.h"
|
||||
#include <alignedtextitem.h>
|
||||
|
||||
|
||||
DeviceItem::DeviceItem(): BlockItem() {
|
||||
addProperty(BlockItem::Property("__type", "", __CV_Device));
|
||||
addProperty(BlockItem::Property("bufferSize", "", 4096));
|
||||
setSize(200, 80);
|
||||
setColor(QColor(192, 192, 255));
|
||||
text_name = new AlignedTextItem();
|
||||
text_path = new AlignedTextItem();
|
||||
QFont fnt(text_name->font()); fnt.setBold(true);
|
||||
text_name->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
||||
text_name->setFont(fnt);
|
||||
text_name->setPos(0., -size().height() / 2.);
|
||||
addDecor(text_name);
|
||||
fnt.setBold(false);
|
||||
fnt.setPointSizeF(fnt.pointSizeF() - 2.);
|
||||
text_path->setFont(fnt);
|
||||
text_path->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
||||
text_path->setPos(0., -size().height() / 2. + 20);
|
||||
addDecor(text_path);
|
||||
addPin(Qt::AlignLeft, 0, "write", "");
|
||||
addPin(Qt::AlignRight, 0, "read", "");
|
||||
}
|
||||
|
||||
|
||||
void DeviceItem::rename() {
|
||||
QString ms;
|
||||
BlockItemPin * pr = pinByText("read"), * pw = pinByText("write");
|
||||
switch (mode()) {
|
||||
case PIIODevice::ReadOnly: ms = "ro"; pr->show(); pw->hide(); break;
|
||||
case PIIODevice::WriteOnly: ms = "wo"; pr->hide(); pw->show(); break;
|
||||
case PIIODevice::ReadWrite: ms = "rw"; pr->show(); pw->show(); break;
|
||||
}
|
||||
text_name->setText(name() + " (" + ms + ")");
|
||||
text_path->setText(path());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
FilterItem::FilterItem(): BlockItem() {
|
||||
addProperty(BlockItem::Property("__type", "", __CV_Filter));
|
||||
addProperty(BlockItem::Property("bufferSize", "", 65536));
|
||||
setSize(140, 80);
|
||||
setPos(200, 0);
|
||||
setColor(QColor(192, 255, 192));
|
||||
text_name = new AlignedTextItem();
|
||||
text_mode = new AlignedTextItem();
|
||||
QFont fnt(text_name->font()); fnt.setBold(true);
|
||||
text_name->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
||||
text_name->setFont(fnt);
|
||||
text_name->setPos(0., -size().height() / 2.);
|
||||
addDecor(text_name);
|
||||
fnt.setBold(false);
|
||||
fnt.setPointSizeF(fnt.pointSizeF() - 2.);
|
||||
text_mode->setFont(fnt);
|
||||
text_mode->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
||||
text_mode->setPos(0., -size().height() / 2. + 20);
|
||||
addDecor(text_mode);
|
||||
addPin(Qt::AlignLeft, 0, "in", "");
|
||||
addPin(Qt::AlignRight, 0, "out", "");
|
||||
}
|
||||
|
||||
|
||||
void FilterItem::rename() {
|
||||
text_name->setText(name());
|
||||
QString ms;
|
||||
PICodeInfo::EnumInfo * ei = PICodeInfo::enumsInfo->value("PIPacketExtractor::SplitMode", 0);
|
||||
if (ei) {
|
||||
piForeachC (PICodeInfo::EnumeratorInfo & i, ei->members)
|
||||
if (i.value == mode()) {
|
||||
ms = PI2QString(i.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
text_mode->setText(ms);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
SenderItem::SenderItem(): BlockItem() {
|
||||
addProperty(BlockItem::Property("__type", "", __CV_Sender));
|
||||
setSize(140, 80);
|
||||
setPos(-200, 0);
|
||||
setColor(QColor(255, 192, 192));
|
||||
text_name = new AlignedTextItem();
|
||||
text_frequency = new AlignedTextItem();
|
||||
QFont fnt(text_name->font()); fnt.setBold(true);
|
||||
text_name->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
||||
text_name->setFont(fnt);
|
||||
text_name->setPos(0., -size().height() / 2.);
|
||||
addDecor(text_name);
|
||||
fnt.setBold(false);
|
||||
fnt.setPointSizeF(fnt.pointSizeF() - 2.);
|
||||
text_frequency->setFont(fnt);
|
||||
text_frequency->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
||||
text_frequency->setPos(0., -size().height() / 2. + 20);
|
||||
addDecor(text_frequency);
|
||||
addPin(Qt::AlignRight, 0, "out", "");
|
||||
}
|
||||
|
||||
|
||||
void SenderItem::rename() {
|
||||
text_name->setText(name());
|
||||
text_frequency->setText(QString::number(frequency()) + " Hz");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ConnectionView::ConnectionView(QWidget * parent): BlockView(parent) {
|
||||
}
|
||||
|
||||
|
||||
ConnectionView::~ConnectionView() {
|
||||
}
|
||||
|
||||
|
||||
DeviceItem * ConnectionView::addDevice(const QString & name, const QString & path) {
|
||||
DeviceItem * ret = findDevice(name);
|
||||
if (ret) return ret;
|
||||
ret = new DeviceItem();
|
||||
PIString dp;
|
||||
PIIODevice::DeviceMode dm;
|
||||
PIIODevice::splitFullPath(Q2PIString(path), &dp, &dm);
|
||||
ret->setPos(0, 0);
|
||||
ret->setName(name);
|
||||
ret->setPath(PI2QString(dp));
|
||||
ret->setMode(dm);
|
||||
ret->setDisconnectTimeout(3.);
|
||||
ret->setBufferSize(4096);
|
||||
placeBlock(ret, allDevices());
|
||||
addItem(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
FilterItem * ConnectionView::addFilter(const QString & name) {
|
||||
FilterItem * ret = new FilterItem();
|
||||
ret->setDisconnectTimeout(3.);
|
||||
ret->setBufferSize(65536);
|
||||
ret->setName(name);
|
||||
placeBlock(ret, allFilters());
|
||||
addItem(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
SenderItem * ConnectionView::addSender(const QString & name) {
|
||||
SenderItem * ret = new SenderItem();
|
||||
ret->setName(name);
|
||||
placeBlock(ret, allSenders());
|
||||
addItem(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
DeviceItem * ConnectionView::findDevice(const QString & name) const {
|
||||
QList<BlockItem*> blockl = blocks();
|
||||
foreach (BlockItem * b, blockl)
|
||||
if ((b->propertyByName("name").value == name) && (b->propertyByName("__type").value.toInt() == __CV_Device))
|
||||
return (DeviceItem*)b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void ConnectionView::loadBus(BlockBusItem * bus) {
|
||||
bus->setEndpointsNumber(2);
|
||||
}
|
||||
|
||||
|
||||
void ConnectionView::placeBlock(BlockItem * b, QList<BlockItem * > coll) {
|
||||
if (coll.isEmpty()) return;
|
||||
QList<QRectF> collr;
|
||||
foreach (BlockItem * i, coll)
|
||||
collr << i->sceneBoundingRect();
|
||||
while (true) {
|
||||
QRectF br = b->sceneBoundingRect();
|
||||
bool ok = true;
|
||||
for (int i = 0; i < collr.size(); ++i)
|
||||
if (br.intersects(collr[i])) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
if (ok) break;
|
||||
b->moveBy(0., grid_step);
|
||||
}
|
||||
b->moveBy(0., grid_step * 2.);
|
||||
}
|
||||
|
||||
|
||||
QList<BlockItem * > ConnectionView::allByType(int type_) const {
|
||||
QList<BlockItem*> blockl = blocks(), ret;
|
||||
foreach (BlockItem * b, blockl)
|
||||
if (b->propertyByName("__type").value.toInt() == type_)
|
||||
ret << b;
|
||||
return ret;
|
||||
}
|
||||
133
libs/piqt_widgets/piqt_connection_view.h
Normal file
133
libs/piqt_widgets/piqt_connection_view.h
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
PIQt Utils - Qt utilites for PIP
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONNECTION_VIEW_H
|
||||
#define CONNECTION_VIEW_H
|
||||
|
||||
#include "blockview.h"
|
||||
#include "piconnection.h"
|
||||
#include "piqt_utils_export.h"
|
||||
|
||||
const int __CV_Device = 1;
|
||||
const int __CV_Filter = 2;
|
||||
const int __CV_Sender = 3;
|
||||
|
||||
|
||||
class PIQT_UTILS_EXPORT DeviceItem: public BlockItem {
|
||||
public:
|
||||
DeviceItem();
|
||||
|
||||
void setName(const QString & n) {addProperty(BlockItem::Property("name", "", n)); rename();}
|
||||
void setPath(const QString & p) {addProperty(BlockItem::Property("device", "", p)); rename();}
|
||||
void setMode(PIIODevice::DeviceMode m) {addProperty(BlockItem::Property("mode", "", int(m))); rename();}
|
||||
void setOptions(PIIODevice::DeviceOptions o) {addProperty(BlockItem::Property("options", "", int(o))); rename();}
|
||||
void setDisconnectTimeout(double v) {addProperty(BlockItem::Property("disconnectTimeout", "", v)); rename();}
|
||||
void setBufferSize(int v) {addProperty(BlockItem::Property("bufferSize", "", v)); rename();}
|
||||
|
||||
QString name() const {return propertyByName("name").value.toString();}
|
||||
QString path() const {return propertyByName("device").value.toString();}
|
||||
PIIODevice::DeviceMode mode() const {return PIIODevice::DeviceMode(propertyByName("mode").value.toInt());}
|
||||
PIIODevice::DeviceOptions options() const {return PIIODevice::DeviceOptions(propertyByName("options").value.toInt());}
|
||||
double disconnectTimeout() const {return propertyByName("disconnectTimeout").value.toDouble();}
|
||||
int bufferSize() const {return propertyByName("bufferSize").value.toInt();}
|
||||
|
||||
void rename();
|
||||
|
||||
protected:
|
||||
AlignedTextItem * text_name, * text_path;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PIQT_UTILS_EXPORT FilterItem: public BlockItem {
|
||||
public:
|
||||
FilterItem();
|
||||
|
||||
void setName(const QString & n) {addProperty(BlockItem::Property("name", "", n)); rename();}
|
||||
void setMode(PIPacketExtractor::SplitMode m) {addProperty(BlockItem::Property("mode", "", int(m))); rename();}
|
||||
void setHeader(const QString & v) {addProperty(BlockItem::Property("header", "", v)); rename();}
|
||||
void setFooter(const QString & v) {addProperty(BlockItem::Property("footer", "", v)); rename();}
|
||||
void setTimeout(double v) {addProperty(BlockItem::Property("timeout", "", v)); rename();}
|
||||
void setPacketSize(int v) {addProperty(BlockItem::Property("size", "", v)); rename();}
|
||||
void setDisconnectTimeout(double v) {addProperty(BlockItem::Property("disconnectTimeout", "", v)); rename();}
|
||||
void setBufferSize(int v) {addProperty(BlockItem::Property("bufferSize", "", v)); rename();}
|
||||
|
||||
QString name() const {return propertyByName("name").value.toString();}
|
||||
PIPacketExtractor::SplitMode mode() const {return PIPacketExtractor::SplitMode(propertyByName("mode").value.toInt());}
|
||||
QString header() const {return propertyByName("header").value.toString();}
|
||||
QString footer() const {return propertyByName("footer").value.toString();}
|
||||
double timeout() const {return propertyByName("timeout").value.toDouble();}
|
||||
int packetSize() const {return propertyByName("size").value.toInt();}
|
||||
double disconnectTimeout() const {return propertyByName("disconnectTimeout").value.toDouble();}
|
||||
int bufferSize() const {return propertyByName("bufferSize").value.toInt();}
|
||||
|
||||
void rename();
|
||||
|
||||
protected:
|
||||
AlignedTextItem * text_name, * text_mode;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PIQT_UTILS_EXPORT SenderItem: public BlockItem {
|
||||
public:
|
||||
SenderItem();
|
||||
|
||||
void setName(const QString & n) {addProperty(BlockItem::Property("name", "", n)); rename();}
|
||||
void setData(const QString & p) {addProperty(BlockItem::Property("data", "", p)); rename();}
|
||||
void setFrequency(double m) {addProperty(BlockItem::Property("frequency", "", m)); rename();}
|
||||
|
||||
QString name() const {return propertyByName("name").value.toString();}
|
||||
QString data() const {return propertyByName("data").value.toString();}
|
||||
double frequency() const {return propertyByName("frequency").value.toDouble();}
|
||||
|
||||
void rename();
|
||||
|
||||
protected:
|
||||
AlignedTextItem * text_name, * text_frequency;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PIQT_UTILS_EXPORT ConnectionView: public BlockView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConnectionView(QWidget * parent = 0);
|
||||
~ConnectionView();
|
||||
|
||||
DeviceItem * addDevice(const QString & name, const QString & path);
|
||||
FilterItem * addFilter(const QString & name);
|
||||
SenderItem * addSender(const QString & name);
|
||||
DeviceItem * findDevice(const QString & name) const;
|
||||
QList<BlockItem * > allDevices() const {return allByType(__CV_Device);}
|
||||
QList<BlockItem * > allFilters() const {return allByType(__CV_Filter);}
|
||||
QList<BlockItem * > allSenders() const {return allByType(__CV_Sender);}
|
||||
|
||||
private:
|
||||
QSize sizeHint() const {return QSize(800, 600);}
|
||||
void loadBus(BlockBusItem * bus);
|
||||
void placeBlock(BlockItem * b, QList<BlockItem*> coll);
|
||||
|
||||
QList<BlockItem * > allByType(int type_) const;
|
||||
|
||||
private slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // CONNECTION_VIEW_H
|
||||
70
libs/piqt_widgets/piqt_highlighter.cpp
Normal file
70
libs/piqt_widgets/piqt_highlighter.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#include "piqt_highlighter.h"
|
||||
|
||||
|
||||
ConfigHighlighter::ConfigHighlighter(QTextDocument * parent): QSyntaxHighlighter(parent) {
|
||||
HighlightingRule rule;
|
||||
|
||||
valueNameFormat.setForeground(QColor(0, 64, 154));
|
||||
rule.pattern = QRegExp("[^=]"); //"\\b[A-Za-z0-9_]+(?=\\()");
|
||||
rule.format = valueNameFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
valueFormat.setForeground(QColor(192, 0, 0));
|
||||
rule.pattern = QRegExp("=[^\n]*");
|
||||
rule.format = valueFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
equalFormat.setFontWeight(QFont::Bold);
|
||||
equalFormat.setForeground(QColor(96, 126, 0));
|
||||
rule.pattern = QRegExp("=");
|
||||
rule.format = equalFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
sectionFormat.setFontWeight(QFont::Bold);
|
||||
sectionFormat.setForeground(QColor(0, 32, 64));
|
||||
rule.pattern = QRegExp("\\[.*\\]");
|
||||
rule.format = sectionFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
//substFormat.setFontWeight(QFont::Bold);
|
||||
substFormat.setForeground(QColor(192, 0, 192));
|
||||
rule.pattern = QRegExp("\\$\\{.*\\}+");
|
||||
rule.pattern.setMinimal(true);
|
||||
rule.format = substFormat;
|
||||
highlightingRules.append(rule);
|
||||
rule.pattern = QRegExp("\\$\\{[^\\{]*\\}+");
|
||||
highlightingRules.append(rule);
|
||||
|
||||
singleLineCommentFormat.setFontItalic(true);
|
||||
singleLineCommentFormat.setForeground(QColor(128, 128, 128));
|
||||
rule.pattern = QRegExp("#[^\n]*");
|
||||
rule.format = singleLineCommentFormat;
|
||||
highlightingRules.append(rule);
|
||||
|
||||
spaceFormat.setForeground(QColor(210, 210, 210));
|
||||
|
||||
//commentStartExpression = QRegExp("/\\*");
|
||||
//commentEndExpression = QRegExp("\\*/");
|
||||
}
|
||||
|
||||
|
||||
void ConfigHighlighter::highlightBlock(const QString & text) {
|
||||
foreach (const HighlightingRule &rule, highlightingRules) {
|
||||
QRegExp expression(rule.pattern);
|
||||
int index = expression.indexIn(text);
|
||||
while (index >= 0) {
|
||||
int length = expression.matchedLength();
|
||||
setFormat(index, length, rule.format);
|
||||
index = expression.indexIn(text, index + length);
|
||||
}
|
||||
}
|
||||
setCurrentBlockState(0);
|
||||
|
||||
QRegExp expression = QRegExp("[ |\t]");
|
||||
int index = expression.indexIn(text);
|
||||
while (index >= 0) {
|
||||
int length = expression.matchedLength();
|
||||
setFormat(index, length, spaceFormat);
|
||||
index = expression.indexIn(text, index + length);
|
||||
}
|
||||
}
|
||||
51
libs/piqt_widgets/piqt_highlighter.h
Normal file
51
libs/piqt_widgets/piqt_highlighter.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
PIQt Utils - Qt utilites for PIP
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONF_HIGHLIGHTER_H
|
||||
#define CONF_HIGHLIGHTER_H
|
||||
|
||||
#include <QSyntaxHighlighter>
|
||||
#include <QTextCursor>
|
||||
#include <QTextCharFormat>
|
||||
#include "piqt_utils_export.h"
|
||||
|
||||
class QTextDocument;
|
||||
|
||||
class PIQT_UTILS_EXPORT ConfigHighlighter : public QSyntaxHighlighter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfigHighlighter(QTextDocument *parent = 0);
|
||||
|
||||
QTextCursor cursor;
|
||||
|
||||
private:
|
||||
void highlightBlock(const QString &text);
|
||||
|
||||
struct PIQT_UTILS_EXPORT HighlightingRule {
|
||||
QRegExp pattern;
|
||||
QTextCharFormat format;
|
||||
};
|
||||
|
||||
QVector<HighlightingRule> highlightingRules;
|
||||
QRegExp commentStartExpression, commentEndExpression;
|
||||
QTextCharFormat singleLineCommentFormat, valueNameFormat, valueFormat, equalFormat, sectionFormat, spaceFormat, substFormat;
|
||||
};
|
||||
|
||||
#endif // CONF_HIGHTLIGHTER_H
|
||||
92
libs/piqt_widgets/piqt_iodevice_edit.cpp
Normal file
92
libs/piqt_widgets/piqt_iodevice_edit.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "piqt_iodevice_edit.h"
|
||||
#include "piqt_iodevice_edit_dialog.h"
|
||||
#include "qvariantedit_custom.h"
|
||||
#include <QLineEdit>
|
||||
#include <QToolButton>
|
||||
#include <QBoxLayout>
|
||||
#include <piqt.h>
|
||||
#include <piiodevice.h>
|
||||
|
||||
|
||||
IODeviceEdit::IODeviceEdit(QWidget * parent): QWidget(parent) {
|
||||
dlg = new IODeviceEditDialog();
|
||||
line = new QLineEdit();
|
||||
btn = new QToolButton();
|
||||
setLayout(new QBoxLayout(QBoxLayout::LeftToRight));
|
||||
layout()->setContentsMargins(0, 0, 0, 0);
|
||||
layout()->addWidget(line);
|
||||
layout()->addWidget(btn);
|
||||
connect(btn, SIGNAL(clicked(bool)), this, SLOT(buttonDlg_clicked()));
|
||||
line->setReadOnly(true);
|
||||
btn->setText(QString());
|
||||
btn->setIcon(QIcon(":/icons/configure.png"));
|
||||
btn->setToolTip(tr("Edit ..."));
|
||||
}
|
||||
|
||||
|
||||
IODeviceEdit::~IODeviceEdit() {
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
|
||||
QVariant IODeviceEdit::value() const {
|
||||
return QVariant::fromValue(dev);
|
||||
}
|
||||
|
||||
|
||||
bool IODeviceEdit::isReadOnly() const {
|
||||
return btn->isHidden();
|
||||
}
|
||||
|
||||
|
||||
void IODeviceEdit::setDevice(const QAD::IODevice & d) {
|
||||
if (dev.toString() == d.toString()) return;
|
||||
dev = d;
|
||||
line->setText(dev.toString());
|
||||
line->setCursorPosition(0);
|
||||
emit valueChanged();
|
||||
}
|
||||
|
||||
|
||||
void IODeviceEdit::setValue(const QVariant & v) {
|
||||
setDevice(v.value<QAD::IODevice>());
|
||||
}
|
||||
|
||||
|
||||
void IODeviceEdit::setReadOnly(bool yes) {
|
||||
btn->setHidden(yes);
|
||||
}
|
||||
|
||||
|
||||
void IODeviceEdit::buttonDlg_clicked() {
|
||||
QAD::IODevice d = dlg->getIODevice(dev);
|
||||
if (!d.isValid()) return;
|
||||
setDevice(d);
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Factory: public QVariantEditorFactoryBase {
|
||||
public:
|
||||
Factory() {}
|
||||
virtual QWidget * createEditor() {return new IODeviceEdit();}
|
||||
};
|
||||
|
||||
|
||||
__IODeviceEditRegistrator__::__IODeviceEditRegistrator__() {
|
||||
QVariantEditorFactories::registerEditorFactory(qMetaTypeId<QAD::IODevice>(), new Factory());
|
||||
__QADTypesRegistrator__::instance()->toString_funcs.insert(qMetaTypeId<QAD::IODevice>(), &QAD_IODevice_toString);
|
||||
}
|
||||
|
||||
|
||||
void QAD_IODevice_toString(const QVariant & v, QString & r) {
|
||||
PIVariantTypes::IODevice sd = Q2PIVariant(v).toIODevice();
|
||||
// piCout << sd;
|
||||
PIIODevice * rd = PIIODevice::createFromVariant(sd);
|
||||
if (rd) {
|
||||
PIString ps = rd->constructFullPath();
|
||||
r = PI2QString(ps);
|
||||
} else {
|
||||
piCout << "error in " << sd;
|
||||
}
|
||||
}
|
||||
74
libs/piqt_widgets/piqt_iodevice_edit.h
Normal file
74
libs/piqt_widgets/piqt_iodevice_edit.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
PIQt Utils - Qt utilites for PIP
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIQT_IODEVICE_EDIT_H
|
||||
#define PIQT_IODEVICE_EDIT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "qad_types.h"
|
||||
#include "piqt_utils_export.h"
|
||||
|
||||
class QLineEdit;
|
||||
class QToolButton;
|
||||
class IODeviceEditDialog;
|
||||
|
||||
|
||||
class PIQT_UTILS_EXPORT IODeviceEdit: public QWidget {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
|
||||
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
|
||||
public:
|
||||
explicit IODeviceEdit(QWidget * parent = 0);
|
||||
~IODeviceEdit();
|
||||
|
||||
QVariant value() const;
|
||||
bool isReadOnly() const;
|
||||
|
||||
private:
|
||||
void setDevice(const QAD::IODevice & d);
|
||||
|
||||
QLineEdit * line;
|
||||
QToolButton * btn;
|
||||
IODeviceEditDialog * dlg;
|
||||
QAD::IODevice dev;
|
||||
|
||||
public slots:
|
||||
void setValue(const QVariant & v);
|
||||
void setReadOnly(bool yes);
|
||||
|
||||
private slots:
|
||||
void buttonDlg_clicked();
|
||||
|
||||
signals:
|
||||
void valueChanged();
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PIQT_UTILS_EXPORT __IODeviceEditRegistrator__ {
|
||||
public:
|
||||
__IODeviceEditRegistrator__();
|
||||
};
|
||||
|
||||
static __IODeviceEditRegistrator__ __iodeviceeditregistrator__;
|
||||
|
||||
PIQT_UTILS_EXPORT void QAD_IODevice_toString(const QVariant & v, QString & r);
|
||||
|
||||
|
||||
#endif // PIQT_IODEVICE_EDIT_H
|
||||
112
libs/piqt_widgets/piqt_iodevice_edit_dialog.cpp
Normal file
112
libs/piqt_widgets/piqt_iodevice_edit_dialog.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
#include "ui_piqt_iodevice_edit_dialog.h"
|
||||
#include "piqt_iodevice_edit_dialog.h"
|
||||
#include "piqt.h"
|
||||
#include "picodeinfo.h"
|
||||
#include "piiodevice.h"
|
||||
#include <QCheckBox>
|
||||
|
||||
|
||||
IODeviceEditDialog::IODeviceEditDialog(QWidget * parent): QDialog(parent) {
|
||||
ui = new Ui::IODeviceEditDialog();
|
||||
ui->setupUi(this);
|
||||
PICodeInfo::EnumInfo * ei = PICodeInfo::enumsInfo->value("PIIODevice::DeviceMode");
|
||||
if (ei) {
|
||||
piForeachC (PICodeInfo::EnumeratorInfo & e, ei->members)
|
||||
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);
|
||||
}
|
||||
}
|
||||
PIStringList pl = PIIODevice::availablePrefixes();
|
||||
piForeachC (PIString & p, pl) {
|
||||
ui->comboType->addItem(PI2QString(p));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
if (!cb) continue;
|
||||
if (cb->isChecked())
|
||||
ret |= cb->property("__value").toInt();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void IODeviceEditDialog::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();
|
||||
cb->setChecked((o & cbf) == cbf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IODeviceEditDialog::on_comboType_currentIndexChanged(int index) {
|
||||
PIString prefix = Q2PIString(ui->comboType->currentText());
|
||||
PIVector<const PIObject * > rd(PICollection::groupElements("__PIIODevices__"));
|
||||
piForeachC (PIObject * d, rd) {
|
||||
const PIIODevice * dev = ((const PIIODevice * )d);
|
||||
if (prefix != dev->fullPathPrefix())
|
||||
continue;
|
||||
ps = PI2QPropertyStorage(dev->constructVariant().get());
|
||||
ui->widgetProperties->setStorage(&ps);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QAD::IODevice IODeviceEditDialog::getIODevice(const QAD::IODevice & d) {
|
||||
setValue(d);
|
||||
if (QDialog::exec() != QDialog::Accepted)
|
||||
return QAD::IODevice();
|
||||
return value();
|
||||
}
|
||||
|
||||
|
||||
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.options = getOptions();
|
||||
d.props = ps;
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
void IODeviceEditDialog::setValue(const QAD::IODevice & d) {
|
||||
#if QT_VERSION >= 0x050000
|
||||
ui->comboType->setCurrentText(d.prefix);
|
||||
#else
|
||||
for (int i = 0; i < ui->comboType->count(); ++i) {
|
||||
if (ui->comboType->itemText(i) == d.prefix) {
|
||||
ui->comboType->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (int i = 0; i < ui->comboMode->count(); ++i)
|
||||
if (ui->comboMode->itemData(i).toInt() == d.mode) {
|
||||
ui->comboMode->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
setOptions(d.options);
|
||||
ps = d.props;
|
||||
ui->widgetProperties->setStorage(&ps);
|
||||
}
|
||||
54
libs/piqt_widgets/piqt_iodevice_edit_dialog.h
Normal file
54
libs/piqt_widgets/piqt_iodevice_edit_dialog.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
PIQt Utils - Qt utilites for PIP
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIQT_IODEVICE_EDIT_DIALOG_H
|
||||
#define PIQT_IODEVICE_EDIT_DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "qad_types.h"
|
||||
#include "propertystorage.h"
|
||||
#include "piqt_utils_export.h"
|
||||
|
||||
namespace Ui {
|
||||
class IODeviceEditDialog;
|
||||
}
|
||||
|
||||
class PIQT_UTILS_EXPORT IODeviceEditDialog: public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IODeviceEditDialog(QWidget * parent = 0);
|
||||
~IODeviceEditDialog();
|
||||
|
||||
QAD::IODevice getIODevice(const QAD::IODevice & d);
|
||||
|
||||
private:
|
||||
QAD::IODevice value() const;
|
||||
void setValue(const QAD::IODevice & d);
|
||||
int getOptions() const;
|
||||
void setOptions(int o);
|
||||
|
||||
PropertyStorage ps;
|
||||
Ui::IODeviceEditDialog * ui;
|
||||
|
||||
private slots:
|
||||
void on_comboType_currentIndexChanged(int index);
|
||||
|
||||
};
|
||||
|
||||
#endif // PIQT_IODEVICE_EDIT_DIALOG_H
|
||||
138
libs/piqt_widgets/piqt_iodevice_edit_dialog.ui
Normal file
138
libs/piqt_widgets/piqt_iodevice_edit_dialog.ui
Normal file
@@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>IODeviceEditDialog</class>
|
||||
<widget class="QDialog" name="IODeviceEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>387</width>
|
||||
<height>345</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>IODevice</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboType"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelFilter_12">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboMode"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelFilter_14">
|
||||
<property name="text">
|
||||
<string>Options:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QVBoxLayout" name="layoutOptions">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="PropertyStorageEditor" name="widgetProperties" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>PropertyStorageEditor</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>propertystorage_editor.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>IODeviceEditDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>227</x>
|
||||
<y>326</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>144</x>
|
||||
<y>302</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>IODeviceEditDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>325</x>
|
||||
<y>315</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>304</x>
|
||||
<y>306</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>recreateConnection()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user