Ocular Engine
LineEdit.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_EDITOR_LINE_EDIT__H__
19 #define __H__OCULAR_EDITOR_LINE_EDIT__H__
20 
21 #include <QtWidgets/qlineedit.h>
22 
23 //------------------------------------------------------------------------------------------
24 
29 namespace Ocular
30 {
35  namespace Editor
36  {
37  enum class LineType
38  {
39  String = 0,
40  Int8,
41  UInt8,
42  Int16,
43  UInt16,
44  Int32,
45  UInt32,
46  Float,
47  Double
48  };
49 
56  class LineEdit : public QLineEdit
57  {
58  Q_OBJECT
59 
60  public:
61 
62  LineEdit(LineType type, QWidget* parent = nullptr);
63  virtual ~LineEdit();
64 
69  bool wasEdited(bool reset = true);
70 
74  void setInvalid(bool invalid);
75 
79  int32_t asInt() const;
80 
84  uint32_t asUint() const;
85 
89  float asFloat() const;
90 
91  template<typename T>
92  T as() const { return OcularString->fromString<T>(text().toStdString()); }
93 
94  protected:
95 
96  private slots:
97 
98  void contentsChanged(QString const& text);
99  void userEdited(QString const& text);
100 
101  private:
102 
103  LineType m_Type;
104  bool m_WasEdited;
105  };
106  }
110 }
115 //------------------------------------------------------------------------------------------
116 
117 #endif
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
bool wasEdited(bool reset=true)
Definition: LineEdit.cpp:90
Definition: LineEdit.hpp:56