1 // lineparalleloptions.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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 06/10/2010 Created this file. :-)
15 #include "lineparalleloptions.h"
17 #include "rs_actiondrawlineparallel.h"
20 LineParallelOptions::LineParallelOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
21 QWidget(parent, flags),
22 lDist(new QLabel(tr("Distance:"))),
23 leDist(new QLineEdit(this)),
24 lNumber(new QLabel(tr("Number:"))),
25 sbNumber(new QSpinBox(this))
27 QHBoxLayout * layout = new QHBoxLayout(this);
28 layout->setContentsMargins(0, 0, 0, 0);
30 leDist->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
32 layout->addWidget(lDist);
33 layout->addWidget(leDist);
34 layout->addWidget(lNumber);
35 layout->addWidget(sbNumber);
37 connect(leDist, SIGNAL(textChanged(QString)), this, SLOT(updateDist(QString)));
38 connect(sbNumber, SIGNAL(valueChanged(int)), this, SLOT(updateNumber(int)));
40 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
41 // nothing will show up on the screen. :-)
43 parent->addWidget(this);
46 LineParallelOptions::~LineParallelOptions()
48 settings.beginGroup("Draw");
49 settings.setValue("LineParallelDistance", leDist->text());
50 settings.setValue("LineParallelNumber", sbNumber->text());
54 void LineParallelOptions::setAction(RS_ActionInterface * a, bool update)
56 if (a != NULL && a->rtti() == RS2::ActionDrawLineParallel)
58 action = (RS_ActionDrawLineParallel *)a;
65 sd = QString("%1").arg(action->getDistance());
66 sn = QString("%1").arg(action->getNumber());
70 settings.beginGroup("Draw");
71 sd = settings.value("LineParallelDistance", "1.0").toString();
72 sn = settings.value("LineParallelNumber", "1").toString();
77 sbNumber->setValue(sn.toInt());
81 RS_DEBUG->print(RS_Debug::D_ERROR, "LineParallelOptions::setAction: wrong action type");
86 void LineParallelOptions::updateDist(const QString & d)
89 action->setDistance(RS_Math::eval(d));
92 void LineParallelOptions::updateNumber(int n)