Salome HOME
Edit arc by dragging
[modules/shaper.git] / src / PartSet / PartSet_EditLine.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_EditLine.h
4 // Created:     02 June 2014
5 // Author:      Natalia ERMOLAEVA
6
7 #include <PartSet_EditLine.h>
8
9 #include <QLineEdit>
10
11 PartSet_EditLine::PartSet_EditLine(QWidget* theParent)
12     : QObject(theParent)
13 {
14   myEditor = new QLineEdit(theParent);
15   myEditor->setWindowFlags(Qt::ToolTip);
16   myEditor->setFocusPolicy(Qt::StrongFocus);
17
18   connect(myEditor, SIGNAL(returnPressed()), this, SLOT(onStopEditing()));
19 }
20
21 void PartSet_EditLine::start(const QPoint& thePoint, double theValue)
22 {
23   myEditor->move(thePoint);
24   myEditor->setText(QString::number(theValue));
25   myEditor->show();
26
27   myEditor->selectAll();
28   myEditor->setFocus();
29 }
30
31 bool PartSet_EditLine::isStarted() const
32 {
33   return myEditor->isVisible();
34 }
35
36 void PartSet_EditLine::stop()
37 {
38   myEditor->hide();
39 }
40
41 double PartSet_EditLine::getValue() const
42 {
43   return myEditor->text().toDouble();
44 }
45
46 void PartSet_EditLine::onStopEditing()
47 {
48   stop();
49   emit stopped(getValue());
50 }