IntEnumWidget.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <QComboBox>
4 
7 
8 #include "../AronTreeWidgetItem.h"
9 #include "CustomWidget.h"
10 
11 namespace armarx::skills::gui
12 {
13  // Custom wrapper around the QComboBox widget to represent IntEnums
14  // This class handles parsing once the user edited the field and is also responsible
15  // to parse the according aron data from text
16  class IntEnumWidget : public CustomWidget
17  {
18  Q_OBJECT
19  public:
20  IntEnumWidget(const aron::type::IntEnumPtr&, QTreeWidgetItem* currentItem);
21  // needs to be called after the constructor, because qt needs the meta object to be fully constructed at this point
22  void postCtorCall();
23 
24  static IntEnumWidget* DynamicCast(QWidget*);
25  static IntEnumWidget* DynamicCastAndCheck(QWidget*);
26 
27  bool hasParseErrors();
28  void setText(const QString& text);
29  QString getText();
30  std::pair<bool, aron::data::IntPtr> parseToAron();
31 
32  private:
33  const aron::type::IntEnumPtr element_type;
34  QComboBox* innerWidget;
35 
36  bool noParseErrors = true;
37 
38  void highlightUnparsableEntries();
39  private slots:
40  void textChanged(const QString&);
41  };
42 } // namespace armarx::skills::gui
armarx::skills::gui::IntEnumWidget::hasParseErrors
bool hasParseErrors()
Definition: IntEnumWidget.cpp:56
armarx::skills::gui::IntEnumWidget
Definition: IntEnumWidget.h:16
armarx::skills::gui::IntEnumWidget::DynamicCast
static IntEnumWidget * DynamicCast(QWidget *)
Definition: IntEnumWidget.cpp:38
Int.h
CustomWidget.h
armarx::skills::gui::IntEnumWidget::DynamicCastAndCheck
static IntEnumWidget * DynamicCastAndCheck(QWidget *)
Definition: IntEnumWidget.cpp:44
armarx::skills::gui::IntEnumWidget::setText
void setText(const QString &text)
Definition: IntEnumWidget.cpp:62
armarx::skills::gui::IntEnumWidget::parseToAron
std::pair< bool, aron::data::IntPtr > parseToAron()
Definition: IntEnumWidget.cpp:75
armarx::skills::gui
Definition: PeriodicUpdateWidget.cpp:11
forward_declarations.h
armarx::skills::gui::CustomWidget
Definition: CustomWidget.h:9
armarx::skills::gui::IntEnumWidget::getText
QString getText()
Definition: IntEnumWidget.cpp:69
armarx::aron::type::IntEnumPtr
std::shared_ptr< IntEnum > IntEnumPtr
Definition: IntEnum.h:36
armarx::skills::gui::IntEnumWidget::IntEnumWidget
IntEnumWidget(const aron::type::IntEnumPtr &, QTreeWidgetItem *currentItem)
Definition: IntEnumWidget.cpp:12
armarx::skills::gui::IntEnumWidget::postCtorCall
void postCtorCall()