~ubuntu-branches/ubuntu/precise/fritzing/precise

« back to all changes in this revision

Viewing changes to src/infoview/htmlinfoview.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Georges Khaznadar
  • Date: 2011-08-26 10:11:05 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110826101105-w5hmn7zcf93ig5v6
Tags: 0.6.3b-1
* upgrapded to the newer upstream version
* parameters of the function GraphicsUtils::distanceFromLine in 
  src/svg/groundplanegenerator.cpp:767 are now declared as doubles,
  which Closes: #636441
* the new version fixes src/utils/folderutils.cpp, which
  Closes: #636061

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
********************************************************************
20
20
 
21
 
$Revision: 5175 $:
 
21
$Revision: 5375 $:
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) $
24
24
 
25
25
********************************************************************/
26
26
 
80
80
        if (t.isEmpty()) return hint;
81
81
 
82
82
        QFontMetricsF fm(this->font());
83
 
        qreal textWidth = fm.width(t);
 
83
        double textWidth = fm.width(t);
84
84
 
85
85
        QWidget * w = this->window();
86
86
        QPoint pos(0,0);
163
163
        m_partVersion->setObjectName("infoViewPartTitle");
164
164
        hboxLayout->addWidget(m_partVersion);
165
165
        
166
 
        m_locationUnits = NULL;
167
 
        m_location = NULL;
168
 
 
169
 
        /*
170
 
        hboxLayout->addSpacing(20);
171
 
        
172
 
        m_locationUnits = new QComboBox();
173
 
        m_location = new QLabel();
174
 
 
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);
180
 
 
181
 
        hboxLayout->addWidget(m_location);
182
 
        connect(m_locationUnits, SIGNAL(currentIndexChanged(int)), this, SLOT(updateLocation()));
183
 
        */
184
 
 
185
166
        hboxLayout->addSpacerItem(new QSpacerItem(IconSpace, 1, QSizePolicy::Expanding));
186
167
        iconFrame->setLayout(hboxLayout);
187
168
        vlo->addWidget(iconFrame);
354
335
}
355
336
 
356
337
void HtmlInfoView::appendStuff(ItemBase* item, bool swappingEnabled) {
357
 
        Wire *wire = dynamic_cast<Wire*>(item);
 
338
        Wire *wire = qobject_cast<Wire*>(item);
358
339
        if (wire) {
359
340
                appendWireStuff(wire, swappingEnabled);
360
341
        } else {
386
367
 
387
368
        setUpTitle(wire);
388
369
        setUpIcons(wire->modelPart());
389
 
        setUpLocation(swappingEnabled ? wire : NULL);
390
370
 
391
371
        displayProps(modelPart, wire, swappingEnabled);
392
372
        addTags(modelPart);
407
387
        setUpTitle(itemBase);
408
388
        setUpIcons(modelPart);
409
389
 
410
 
        setUpLocation(swappingEnabled ? itemBase : NULL);
411
 
 
412
390
        QString nameString;
413
391
        if (swappingEnabled) {
414
392
                nameString = (itemBase) ? itemBase->title() : modelPart->title();
492
470
        displayProps(NULL, NULL, false);
493
471
        addTags(NULL);
494
472
        viewConnectorItemInfo(NULL);
495
 
        setUpLocation(NULL);
496
473
        m_connFrame->setVisible(false);
497
474
        m_propFrame->setVisible(false);
498
475
        m_proplabel->setVisible(false);
501
478
}
502
479
 
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;
512
489
}
513
490
 
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
518
495
        }
519
496
}
520
497
 
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
525
502
        }
526
503
}
527
504
 
528
505
void HtmlInfoView::instanceTitleEditable(bool editable) {
529
 
        FLineEdit * edit = dynamic_cast<FLineEdit *>(sender());
 
506
        FLineEdit * edit = qobject_cast<FLineEdit *>(sender());
530
507
        if (editable) {
531
508
                setInstanceTitleColors(edit, QColor(0xff, 0xff, 0xff), QColor(0x00, 0x00, 0x00)); //fcfcfc, 000000
532
509
        }
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();
844
821
        return pixmap;
845
822
}
846
823
 
847
 
void HtmlInfoView::setUpLocation(ItemBase * itemBase) {
848
 
        if (m_location == NULL) return;
849
 
        if (m_locationUnits == NULL) return;
850
 
 
851
 
        if (itemBase == NULL) {
852
 
                m_location->setText("");
853
 
                m_locationUnits->setVisible(false);
854
 
                return;
855
 
        }
856
 
 
857
 
        m_locationUnits->setVisible(true);
858
 
        QPointF p = itemBase->pos();
859
 
        qreal x = p.x() / FSvgRenderer::printerScale();
860
 
        qreal y = p.y() / FSvgRenderer::printerScale();
861
 
 
862
 
        qreal units = (m_locationUnits->currentText().compare("in") == 0) ? 1.0 : 25.4;
863
 
 
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)
872
 
                );
873
 
                return;
874
 
        }
875
 
 
876
 
        m_location->setText(tr("x:%1\ny:%2")
877
 
                .arg(x * units, 0, 'f', 3)
878
 
                .arg(y * units, 0, 'f', 3)
879
 
        );
880
 
}
881
 
 
882
 
void HtmlInfoView::updateLocation() {
883
 
        setUpLocation(m_currentItem);
884
 
}
885
 
 
886
824
QHash<QString, QString> HtmlInfoView::getPartProperties(ModelPart * modelPart, ItemBase * itemBase, bool wantDebug, QStringList & keys) 
887
825
{
888
826
        QHash<QString, QString> properties;