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 Q_PROPERTY(bool angle READ isAngle WRITE setAngle);
39 Q_PROPERTY(bool integer READ isInteger WRITE setInteger);
40 //Q_PROPERTY(double defaultValue READ getDefaultValue WRITE setDefaultValue);
41 //Q_PROPERTY(int defaultUnit READ getDefaultUnit WRITE setDefaultUnit);
42 //Q_PROPERTY(RS::Unit defaultUnit READ getDefaultUnit WRITE setDefaultUnit);
43 //Q_ENUMS(RS::Unit);
44 
45 public:
46  RMathLineEdit(QWidget* parent = NULL);
47 
48  bool isAngle() const {
49  return angle;
50  }
51  void setAngle(bool on) {
52  angle = on;
53  }
54  bool isInteger() const {
55  return integer;
56  }
57  void setInteger(bool on) {
58  integer = on;
59  }
60 
61  void setValue(double v, int precision=6);
62  double getValue();
63  QString getError();
64  void clearError();
65 
66  bool isValid() {
67  return !RMath::isNaN(value);
68  }
69 
70  void setToolTip(const QString& toolTip);
71 
72  /*
73  double getDefaultValue() {
74  return defaultValue;
75  }
76  void setDefaultValue(double v) {
77  defaultValue = v;
78  }
79  */
80 
81  //void setDefaultUnit(int defaultUnit);
82  //int getDefaultUnit();
83 
84 protected:
85  virtual void keyPressEvent(QKeyEvent* event);
86  virtual void keyReleaseEvent(QKeyEvent* event);
87 // virtual bool eventFilter(QObject* obj, QEvent* event);
88 
89 public slots:
90  void slotTextChanged(const QString& text);
91  void slotTextEdited(const QString& text);
92 
93 signals:
94  void valueChanged(double value, const QString& error);
95  void upKeyPressed();
96  void downKeyPressed();
97  void enterKeyPressed();
98 
99 private:
100  QPalette oriPalette;
101  bool angle;
102  bool integer;
103  double value;
104  //RS::Unit defaultUnit;
105  QString error;
107  bool noEmit;
109  //double defaultValue;
110 // QLabel* resultTip;
111 };
112 
114 
115 #endif
bool isAngle() const
Definition: RMathLineEdit.h:48
bool noEmit
Definition: RMathLineEdit.h:107
#define QCADGUI_EXPORT
Definition: gui_global.h:10
QPalette oriPalette
Definition: RMathLineEdit.h:100
bool isValid()
Definition: RMathLineEdit.h:66
QString error
Definition: RMathLineEdit.h:105
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:57
double value
Definition: RMathLineEdit.h:103
QString originalToolTip
Definition: RMathLineEdit.h:106
void setAngle(bool on)
Definition: RMathLineEdit.h:51
bool noResultInToolTip
Definition: RMathLineEdit.h:108
bool isInteger() const
Definition: RMathLineEdit.h:54