QCAD
Open Source 2D CAD
RMathLineEdit.h
Go to the documentation of this file.
1 
20 #ifndef RMATHLINEEDIT_H_
21 #define RMATHLINEEDIT_H_
22 
23 #include "gui_global.h"
24 
25 #include <QMetaType>
26 #include <QLabel>
27 #include <QLineEdit>
28 
29 #include "RMath.h"
30 
35 class QCADGUI_EXPORT RMathLineEdit: public QLineEdit {
36 
37 Q_OBJECT
38 
39 // keep extra ';' in place for the benefit of ecmagenerator:
40 Q_PROPERTY(bool angle READ isAngle WRITE setAngle);
41 Q_PROPERTY(bool integer READ isInteger WRITE setInteger);
42 //Q_PROPERTY(double defaultValue READ getDefaultValue WRITE setDefaultValue);
43 //Q_PROPERTY(int defaultUnit READ getDefaultUnit WRITE setDefaultUnit);
44 //Q_PROPERTY(RS::Unit defaultUnit READ getDefaultUnit WRITE setDefaultUnit);
45 //Q_ENUMS(RS::Unit);
46 
47 public:
48  RMathLineEdit(QWidget* parent = NULL);
49 
50  bool isAngle() const {
51  return angle;
52  }
53  void setAngle(bool on) {
54  angle = on;
55  }
56  bool isInteger() const {
57  return integer;
58  }
59  void setInteger(bool on) {
60  integer = on;
61  }
62 
63  void setValue(double v, int precision=6);
64  double getValue();
65  QString getError();
66  void clearError();
67 
68  bool isValid() {
69  return !RMath::isNaN(value);
70  }
71 
72  void setToolTip(const QString& toolTip);
73 
74  /*
75  double getDefaultValue() {
76  return defaultValue;
77  }
78  void setDefaultValue(double v) {
79  defaultValue = v;
80  }
81  */
82 
83  //void setDefaultUnit(int defaultUnit);
84  //int getDefaultUnit();
85 
86 protected:
87  virtual void keyPressEvent(QKeyEvent* event);
88  virtual void keyReleaseEvent(QKeyEvent* event);
89 // virtual bool eventFilter(QObject* obj, QEvent* event);
90 
91 public slots:
92  void slotTextChanged(const QString& text);
93  void slotTextEdited(const QString& text);
94 
95 signals:
96  void valueChanged(double value, const QString& error);
97  void upKeyPressed();
98  void downKeyPressed();
99  void enterKeyPressed();
100 
101 private:
102  QPalette oriPalette;
103  bool angle;
104  bool integer;
105  double value;
106  //RS::Unit defaultUnit;
107  QString error;
109  bool noEmit;
111  //double defaultValue;
112 // QLabel* resultTip;
113 };
114 
116 
117 #endif
bool isAngle() const
Definition: RMathLineEdit.h:50
bool noEmit
Definition: RMathLineEdit.h:109
#define QCADGUI_EXPORT
Definition: gui_global.h:10
QPalette oriPalette
Definition: RMathLineEdit.h:102
bool isValid()
Definition: RMathLineEdit.h:68
QString error
Definition: RMathLineEdit.h:107
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RMathLineEdit.h:35
Q_DECLARE_METATYPE(RMath *)
static bool isNaN(double v)
Definition: RMath.cpp:106
void setInteger(bool on)
Definition: RMathLineEdit.h:59
double value
Definition: RMathLineEdit.h:105
QString originalToolTip
Definition: RMathLineEdit.h:108
void setAngle(bool on)
Definition: RMathLineEdit.h:53
bool noResultInToolTip
Definition: RMathLineEdit.h:110
bool isInteger() const
Definition: RMathLineEdit.h:56