19
19
********************************************************************
22
22
$Author: cohen@irascible.com $:
23
$Date: 2011-07-04 23:05:58 +0200 (Mon, 04 Jul 2011) $
23
$Date: 2011-08-08 21:38:25 +0200 (Mon, 08 Aug 2011) $
25
25
********************************************************************/
80
80
if (t.isEmpty()) return hint;
82
82
QFontMetricsF fm(this->font());
83
qreal textWidth = fm.width(t);
83
double textWidth = fm.width(t);
85
85
QWidget * w = this->window();
163
163
m_partVersion->setObjectName("infoViewPartTitle");
164
164
hboxLayout->addWidget(m_partVersion);
166
m_locationUnits = NULL;
170
hboxLayout->addSpacing(20);
172
m_locationUnits = new QComboBox();
173
m_location = new QLabel();
175
m_locationUnits->addItem("in");
176
m_locationUnits->addItem("mm");
177
m_locationUnits->setCurrentIndex(0);
178
m_locationUnits->setVisible(false);
179
hboxLayout->addWidget(m_locationUnits);
181
hboxLayout->addWidget(m_location);
182
connect(m_locationUnits, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLocation()));
185
166
hboxLayout->addSpacerItem(new QSpacerItem(IconSpace, 1, QSizePolicy::Expanding));
186
167
iconFrame->setLayout(hboxLayout);
187
168
vlo->addWidget(iconFrame);
356
337
void HtmlInfoView::appendStuff(ItemBase* item, bool swappingEnabled) {
357
Wire *wire = dynamic_cast<Wire*>(item);
338
Wire *wire = qobject_cast<Wire*>(item);
359
340
appendWireStuff(wire, swappingEnabled);
492
470
displayProps(NULL, NULL, false);
494
472
viewConnectorItemInfo(NULL);
496
473
m_connFrame->setVisible(false);
497
474
m_propFrame->setVisible(false);
498
475
m_proplabel->setVisible(false);
503
480
void HtmlInfoView::setInstanceTitle() {
504
FLineEdit * edit = dynamic_cast<FLineEdit *>(sender());
481
FLineEdit * edit = qobject_cast<FLineEdit *>(sender());
505
482
if (edit == NULL) return;
506
483
if (!edit->isEnabled()) return;
507
484
if (m_infoGraphicsView == NULL) return;
514
491
void HtmlInfoView::instanceTitleEnter() {
515
FLineEdit * edit = dynamic_cast<FLineEdit *>(sender());
492
FLineEdit * edit = qobject_cast<FLineEdit *>(sender());
516
493
if (edit->isEnabled()) {
517
494
setInstanceTitleColors(edit, QColor(0xeb, 0xeb, 0xee), QColor(0x00, 0x00, 0x00)); //c8c8c8, 575757
521
498
void HtmlInfoView::instanceTitleLeave() {
522
FLineEdit * edit = dynamic_cast<FLineEdit *>(sender());
499
FLineEdit * edit = qobject_cast<FLineEdit *>(sender());
523
500
if (edit->isEnabled()) {
524
501
setInstanceTitleColors(edit, QColor(0xd2, 0xd2, 0xd7), QColor(0x00, 0x00, 0x00)); //b3b3b3, 575757
528
505
void HtmlInfoView::instanceTitleEditable(bool editable) {
529
FLineEdit * edit = dynamic_cast<FLineEdit *>(sender());
506
FLineEdit * edit = qobject_cast<FLineEdit *>(sender());
531
508
setInstanceTitleColors(edit, QColor(0xff, 0xff, 0xff), QColor(0x00, 0x00, 0x00)); //fcfcfc, 000000
829
806
QPainter painter(pixmap);
830
807
// preserve aspect ratio
831
808
QSize def = renderer.defaultSize();
832
qreal newW = size.width();
833
qreal newH = newW * def.height() / def.width();
809
double newW = size.width();
810
double newH = newW * def.height() / def.width();
834
811
if (newH > size.height()) {
835
812
newH = size.height();
836
813
newW = newH * def.width() / def.height();
847
void HtmlInfoView::setUpLocation(ItemBase * itemBase) {
848
if (m_location == NULL) return;
849
if (m_locationUnits == NULL) return;
851
if (itemBase == NULL) {
852
m_location->setText("");
853
m_locationUnits->setVisible(false);
857
m_locationUnits->setVisible(true);
858
QPointF p = itemBase->pos();
859
qreal x = p.x() / FSvgRenderer::printerScale();
860
qreal y = p.y() / FSvgRenderer::printerScale();
862
qreal units = (m_locationUnits->currentText().compare("in") == 0) ? 1.0 : 25.4;
864
if (itemBase->itemType() == ModelPart::Wire) {
865
Wire * wire = qobject_cast<Wire *>(itemBase);
866
QPointF q = p + wire->line().p2();
867
m_location->setText(tr("x:%1 %2\ny:%3 %4")
868
.arg(x * units, 0, 'f', 3)
869
.arg(q.x() * units / FSvgRenderer::printerScale(), 0, 'f', 3)
870
.arg(y * units, 0, 'f', 3)
871
.arg(q.y() * units / FSvgRenderer::printerScale(), 0, 'f', 3)
876
m_location->setText(tr("x:%1\ny:%2")
877
.arg(x * units, 0, 'f', 3)
878
.arg(y * units, 0, 'f', 3)
882
void HtmlInfoView::updateLocation() {
883
setUpLocation(m_currentItem);
886
824
QHash<QString, QString> HtmlInfoView::getPartProperties(ModelPart * modelPart, ItemBase * itemBase, bool wantDebug, QStringList & keys)
888
826
QHash<QString, QString> properties;