1 // dimensionlabeleditor.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 06/11/2010 Created this file. :-)
17 #include "dimensionlabeleditor.h"
20 //#include "drawing.h"
23 DimensionLabelEditor::DimensionLabelEditor(QWidget * parent/*= NULL*/, Qt::WindowFlags flags/*= 0*/):
24 QWidget(parent, flags)
29 DimensionLabelEditor::~DimensionLabelEditor()
33 void DimensionLabelEditor::setLabel(const QString & l)
36 QString label, tol1, tol2;
37 bool hasDiameter = false;
41 if (label.at(0) == QChar(0x2205) || label.at(0) == QChar(0xF8))
44 ui.bDiameter->setChecked(true);
47 i0 = l.indexOf("\\S");
51 i1a = l.indexOf("^ ", i0);
55 i1a = i1b = l.indexOf('^', i0);
60 i2 = l.indexOf(';', i1b);
62 tol1 = l.mid(i0 + 2, i1a - i0 - 2);
63 tol2 = l.mid(i1b + 1, i2 - i1b - 1);
67 ui.leLabel->setText(label.mid(hasDiameter));
68 ui.leTol1->setText(tol1);
69 ui.leTol2->setText(tol2);
72 QString DimensionLabelEditor::getLabel()
74 QString l = ui.leLabel->text();
77 if (ui.bDiameter->isChecked())
80 l = QString("%1<>").arg(QChar(0x2205));
82 l = QChar(0x2205) + l;
85 if (ui.leTol1->text().isEmpty() && ui.leTol2->text().isEmpty())
88 return l + "\\S" + ui.leTol1->text() + "^ " + ui.leTol2->text() + ";";
91 void DimensionLabelEditor::insertSign(const QString & s)
93 ui.leLabel->insert(s.left(1));