2021-04-04 21:04:12 +01:00
|
|
|
#include "PinWidget.hpp"
|
|
|
|
|
|
2021-07-07 20:54:45 +01:00
|
|
|
using namespace Bloom::Widgets::InsightTargetWidgets::Dip;
|
2021-05-24 20:58:49 +01:00
|
|
|
using namespace Bloom::Targets;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2021-09-04 18:03:45 +01:00
|
|
|
PinWidget::PinWidget(
|
|
|
|
|
const TargetPinDescriptor& pinDescriptor,
|
|
|
|
|
const TargetVariant& targetVariant,
|
|
|
|
|
InsightWorker& insightWorker,
|
|
|
|
|
QWidget* parent
|
|
|
|
|
): TargetPinWidget(pinDescriptor, targetVariant, insightWorker, parent) {
|
2021-04-04 21:04:12 +01:00
|
|
|
this->layout = new QVBoxLayout();
|
2021-08-18 22:51:15 +01:00
|
|
|
this->layout->setContentsMargins(0, 0, 0, 0);
|
2021-04-04 21:04:12 +01:00
|
|
|
this->layout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
this->bodyWidget = new PinBodyWidget(this, this->pinDescriptor);
|
|
|
|
|
bool isTopWidget = pinDescriptor.number > (targetVariant.pinDescriptorsByNumber.size() / 2);
|
|
|
|
|
|
|
|
|
|
this->layout->setAlignment(isTopWidget ? (Qt::AlignmentFlag::AlignHCenter | Qt::AlignmentFlag::AlignBottom)
|
|
|
|
|
: (Qt::AlignmentFlag::AlignHCenter | Qt::AlignmentFlag::AlignTop));
|
|
|
|
|
|
|
|
|
|
this->pinDirectionLabel = new QLabel(this);
|
|
|
|
|
this->pinDirectionLabel->setObjectName("target-pin-direction");
|
|
|
|
|
this->pinDirectionLabel->setAlignment(Qt::AlignmentFlag::AlignCenter);
|
|
|
|
|
|
2021-06-26 03:42:16 +01:00
|
|
|
auto pinName = QString::fromStdString(pinDescriptor.name).toUpper();
|
2021-04-04 21:04:12 +01:00
|
|
|
this->pinNameLabel = new QLabel(this);
|
|
|
|
|
this->pinNameLabel->setObjectName("target-pin-name");
|
2021-06-26 03:42:16 +01:00
|
|
|
this->pinNameLabel->setToolTip(pinName);
|
|
|
|
|
if (pinName.size() > 4) {
|
|
|
|
|
pinName.truncate(4);
|
|
|
|
|
}
|
|
|
|
|
this->pinNameLabel->setText(pinName);
|
2021-04-04 21:04:12 +01:00
|
|
|
this->pinNameLabel->setAlignment(Qt::AlignmentFlag::AlignCenter);
|
|
|
|
|
|
|
|
|
|
this->pinNumberLabel = new QLabel(this);
|
|
|
|
|
this->pinNumberLabel->setObjectName("target-pin-number");
|
|
|
|
|
this->pinNumberLabel->setText(QString::number(pinDescriptor.number));
|
|
|
|
|
this->pinNumberLabel->setAlignment(Qt::AlignmentFlag::AlignCenter);
|
|
|
|
|
|
|
|
|
|
if (isTopWidget) {
|
|
|
|
|
this->layout->setDirection(QBoxLayout::Direction::BottomToTop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->layout->addWidget(this->bodyWidget);
|
|
|
|
|
this->layout->insertSpacing(1, 3);
|
|
|
|
|
this->layout->addWidget(this->pinNumberLabel);
|
|
|
|
|
this->layout->insertSpacing(3, 2);
|
|
|
|
|
this->layout->addWidget(this->pinNameLabel);
|
|
|
|
|
this->layout->insertSpacing(5, 2);
|
|
|
|
|
this->layout->addWidget(this->pinDirectionLabel);
|
|
|
|
|
this->pinNameLabel->setFixedSize(PinBodyWidget::WIDTH, PinWidget::LABEL_HEIGHT - 2);
|
|
|
|
|
this->pinNumberLabel->setFixedSize(PinBodyWidget::WIDTH, PinWidget::LABEL_HEIGHT - 2);
|
|
|
|
|
|
|
|
|
|
this->setFixedSize(PinWidget::MINIMUM_WIDTH, PinWidget::MAXIMUM_HEIGHT);
|
|
|
|
|
this->setLayout(this->layout);
|
|
|
|
|
|
|
|
|
|
connect(this->bodyWidget, &PinBodyWidget::clicked, this, &TargetPinWidget::onWidgetBodyClicked);
|
|
|
|
|
}
|