code format
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "piqt_connection_view.h"
|
||||
|
||||
#include "picodeinfo.h"
|
||||
#include "piqt.h"
|
||||
|
||||
#include <alignedtextitem.h>
|
||||
|
||||
|
||||
@@ -11,7 +13,8 @@ DeviceItem::DeviceItem(): BlockItem() {
|
||||
setColor(QColor(192, 192, 255));
|
||||
text_name = new AlignedTextItem();
|
||||
text_path = new AlignedTextItem();
|
||||
QFont fnt(text_name->font()); fnt.setBold(true);
|
||||
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.);
|
||||
@@ -29,19 +32,29 @@ DeviceItem::DeviceItem(): BlockItem() {
|
||||
|
||||
void DeviceItem::rename() {
|
||||
QString ms;
|
||||
BlockItemPin * pr = pinByText("read"), * pw = pinByText("write");
|
||||
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;
|
||||
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));
|
||||
@@ -50,7 +63,8 @@ FilterItem::FilterItem(): BlockItem() {
|
||||
setColor(QColor(192, 255, 192));
|
||||
text_name = new AlignedTextItem();
|
||||
text_mode = new AlignedTextItem();
|
||||
QFont fnt(text_name->font()); fnt.setBold(true);
|
||||
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.);
|
||||
@@ -71,9 +85,9 @@ void FilterItem::rename() {
|
||||
QString ms;
|
||||
PICodeInfo::EnumInfo * ei = PICodeInfo::enumsInfo->value("PIPacketExtractor::SplitMode", 0);
|
||||
if (ei) {
|
||||
piForeachC (PICodeInfo::EnumeratorInfo & i, ei->members)
|
||||
piForeachC(PICodeInfo::EnumeratorInfo & i, ei->members)
|
||||
if (i.value == mode()) {
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2,39,0)
|
||||
#if PIP_VERSION >= PIP_MAKE_VERSION(2, 39, 0)
|
||||
ms = PI2QString(i.name.toString());
|
||||
#else
|
||||
ms = PI2QString(i.name);
|
||||
@@ -82,20 +96,18 @@ void FilterItem::rename() {
|
||||
}
|
||||
}
|
||||
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_name = new AlignedTextItem();
|
||||
text_frequency = new AlignedTextItem();
|
||||
QFont fnt(text_name->font()); fnt.setBold(true);
|
||||
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.);
|
||||
@@ -116,14 +128,10 @@ void SenderItem::rename() {
|
||||
}
|
||||
|
||||
|
||||
ConnectionView::ConnectionView(QWidget * parent): BlockView(parent) {}
|
||||
|
||||
|
||||
ConnectionView::ConnectionView(QWidget * parent): BlockView(parent) {
|
||||
}
|
||||
|
||||
|
||||
ConnectionView::~ConnectionView() {
|
||||
}
|
||||
ConnectionView::~ConnectionView() {}
|
||||
|
||||
|
||||
DeviceItem * ConnectionView::addDevice(const QString & name, const QString & path) {
|
||||
@@ -166,10 +174,9 @@ SenderItem * ConnectionView::addSender(const QString & name) {
|
||||
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -179,14 +186,14 @@ void ConnectionView::loadBus(BlockBusItem * bus) {
|
||||
}
|
||||
|
||||
|
||||
void ConnectionView::placeBlock(BlockItem * b, QList<BlockItem * > coll) {
|
||||
void ConnectionView::placeBlock(BlockItem * b, QList<BlockItem *> coll) {
|
||||
if (coll.isEmpty()) return;
|
||||
QList<QRectF> collr;
|
||||
foreach (BlockItem * i, coll)
|
||||
foreach(BlockItem * i, coll)
|
||||
collr << i->sceneBoundingRect();
|
||||
while (true) {
|
||||
QRectF br = b->sceneBoundingRect();
|
||||
bool ok = true;
|
||||
bool ok = true;
|
||||
for (int i = 0; i < collr.size(); ++i)
|
||||
if (br.intersects(collr[i])) {
|
||||
ok = false;
|
||||
@@ -199,10 +206,9 @@ void ConnectionView::placeBlock(BlockItem * b, QList<BlockItem * > coll) {
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user