From 0bee9f241298b4e6360b621ab53f616113479ae8 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Mar 2023 18:46:30 +0100 Subject: [PATCH 1/9] CustomEventFilters.h: rm Q_OBJECT from classes w/o signals and slots --- GUI/Support/Util/CustomEventFilters.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/GUI/Support/Util/CustomEventFilters.h b/GUI/Support/Util/CustomEventFilters.h index ab4ab13e411..453b67b64b9 100644 --- a/GUI/Support/Util/CustomEventFilters.h +++ b/GUI/Support/Util/CustomEventFilters.h @@ -20,7 +20,6 @@ //! Filter out space bar key events, which is special case for dialog windows. class SpaceKeyEater : public QObject { - Q_OBJECT public: SpaceKeyEater(QObject* parent = nullptr); @@ -32,7 +31,6 @@ protected: //! to react on wheel events during scrolling of InstrumentComponentWidget. class WheelEventEater : public QObject { - Q_OBJECT public: static void install(QObject* obj); WheelEventEater(QObject* parent = nullptr); @@ -61,7 +59,6 @@ signals: //! Event filter to prevent lost of focus by custom material editor. class LostFocusFilter : public QObject { - Q_OBJECT public: LostFocusFilter(QObject* parent = nullptr); @@ -88,7 +85,6 @@ protected: //! Filter out right mouse button events. class RightMouseButtonEater : public QObject { - Q_OBJECT public: RightMouseButtonEater(QObject* parent = nullptr); @@ -99,7 +95,6 @@ protected: //! Propagate tab events from focusProxy to parent. class TabFromFocusProxy : public QObject { - Q_OBJECT public: TabFromFocusProxy(QWidget* parent = nullptr); -- GitLab From bc5aca6fa1d1093020c0bf7ca24f3570407ba60d Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Mar 2023 18:48:02 +0100 Subject: [PATCH 2/9] ScientificSpinBox: label -> private; Q_OBJECT + note --- GUI/View/Numeric/ScientificSpinBox.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/GUI/View/Numeric/ScientificSpinBox.h b/GUI/View/Numeric/ScientificSpinBox.h index bafe78296b3..28b7ae1a6e9 100644 --- a/GUI/View/Numeric/ScientificSpinBox.h +++ b/GUI/View/Numeric/ScientificSpinBox.h @@ -18,8 +18,7 @@ #include <QAbstractSpinBox> class ScientificSpinBox : public QAbstractSpinBox { - Q_OBJECT - + Q_OBJECT // needed by qobject_cast Q_PROPERTY(double value MEMBER m_value READ value WRITE setValue NOTIFY valueChanged USER true) public: ScientificSpinBox(QWidget* parent = nullptr); @@ -52,10 +51,9 @@ public: signals: void valueChanged(double value); -protected: +private: QAbstractSpinBox::StepEnabled stepEnabled() const override; -private: void updateValue(); void updateText(); bool inRange(double val) const; -- GitLab From 7735ee35f33f007028c4f6e1e1e5ff95a867235a Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Mar 2023 18:55:10 +0100 Subject: [PATCH 3/9] JobWorker + note to protect Q_OBJECT --- GUI/Support/Data/JobWorker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI/Support/Data/JobWorker.h b/GUI/Support/Data/JobWorker.h index fc929fd8cde..dc223a70bc7 100644 --- a/GUI/Support/Data/JobWorker.h +++ b/GUI/Support/Data/JobWorker.h @@ -26,7 +26,7 @@ class SimulationResult; //! The JobWorker class provides running the domain simulation in a thread. class JobWorker : public QObject { - Q_OBJECT + Q_OBJECT // needed by qobject_cast public: JobWorker(QString identifier, ISimulation* simulation); ~JobWorker(); -- GitLab From 604d9aa97d87147602086d7f0335d191c6709041 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Mar 2023 23:11:24 +0100 Subject: [PATCH 4/9] CustomEditor + note to protect Q_OBJECT --- GUI/View/PropertyEditor/CustomEditors.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI/View/PropertyEditor/CustomEditors.h b/GUI/View/PropertyEditor/CustomEditors.h index 58c657a8eaf..418a2668a3e 100644 --- a/GUI/View/PropertyEditor/CustomEditors.h +++ b/GUI/View/PropertyEditor/CustomEditors.h @@ -26,7 +26,7 @@ class RealLimits; //! Base class for all custom variants editors. class CustomEditor : public QWidget { - Q_OBJECT + Q_OBJECT // needed by qobject_cast public: explicit CustomEditor(QWidget* parent = nullptr) : QWidget(parent) -- GitLab From ecd9bca0557e3d3eb5aa5b2cc0931ba44d693f0b Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Mar 2023 23:13:56 +0100 Subject: [PATCH 5/9] SizeHandleElement + note to protect Q_OBJECT --- GUI/View/Mask/SizeHandleElement.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI/View/Mask/SizeHandleElement.h b/GUI/View/Mask/SizeHandleElement.h index e811fac2bcd..34f7f873e35 100644 --- a/GUI/View/Mask/SizeHandleElement.h +++ b/GUI/View/Mask/SizeHandleElement.h @@ -24,7 +24,7 @@ //! Placed either in corners on in the middle of the edge. class SizeHandleElement : public QGraphicsObject { - Q_OBJECT + Q_OBJECT // needed by qobject_cast public: int type() const override { return MaskEditorHelper::SIZEHANDLE; } -- GitLab From 458ea1908bd4935856bbc799c912f2abbda20de3 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Mar 2023 23:35:16 +0100 Subject: [PATCH 6/9] templated fct defs -> class def --- GUI/View/SampleDesigner/FormLayouter.h | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/GUI/View/SampleDesigner/FormLayouter.h b/GUI/View/SampleDesigner/FormLayouter.h index 340e86fed4f..f58863792d5 100644 --- a/GUI/View/SampleDesigner/FormLayouter.h +++ b/GUI/View/SampleDesigner/FormLayouter.h @@ -81,7 +81,11 @@ public: //! For more details, see SelectionContainerForm. //! Returns the newly added row. template <typename T> - int addSelection(SelectionProperty<T>& d); + int addSelection(SelectionProperty<T>& d) + { + auto* w = new SelectionContainerForm(m_formLayout->parentWidget(), d, m_ec); + return addRow(d.label(), w); + } //! Adds a row with a bold printed label and a DoubleSpinBox. //! @@ -146,27 +150,15 @@ public: void addStructureEditingRow(QPushButton* button); //! Find a widget in the given position. - //! - //! The widget will be qobject_cast'ed to the template parameter template <typename T> - T widgetAt(int row, QFormLayout::ItemRole role); + T widgetAt(int row, QFormLayout::ItemRole role) + { + return qobject_cast<T>(m_formLayout->itemAt(row, role)->widget()); + } private: SampleEditorController* m_ec; QFormLayout* m_formLayout; }; -template <typename T> -int FormLayouter::addSelection(SelectionProperty<T>& d) -{ - auto* w = new SelectionContainerForm(m_formLayout->parentWidget(), d, m_ec); - return addRow(d.label(), w); -} - -template <typename T> -T FormLayouter::widgetAt(int row, QFormLayout::ItemRole role) -{ - return qobject_cast<T>(m_formLayout->itemAt(row, role)->widget()); -} - #endif // BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_FORMLAYOUTER_H -- GitLab From 80b3fd8f12dc817850f6ae0e80d8fb2141223f07 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Mar 2023 23:46:33 +0100 Subject: [PATCH 7/9] DoubleSpinBox + note to protect Q_OBJECT --- GUI/View/Numeric/DoubleSpinBox.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI/View/Numeric/DoubleSpinBox.h b/GUI/View/Numeric/DoubleSpinBox.h index a544519a297..050f313c7e3 100644 --- a/GUI/View/Numeric/DoubleSpinBox.h +++ b/GUI/View/Numeric/DoubleSpinBox.h @@ -19,7 +19,7 @@ //! SpinBox for DoubleProperties, supporting units. class DoubleSpinBox : public QDoubleSpinBox { - Q_OBJECT + Q_OBJECT // required by qobject_cast (called via FormLayouter::widgetAt) public: //! Create a DoubleSpinBox with the information found in a DoubleProperty. //! -- GitLab From 5473f68830be3b25351aaa5437ae3300cfd88807 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Mar 2023 23:51:15 +0100 Subject: [PATCH 8/9] LayerForm + clueless note --- GUI/View/SampleDesigner/LayerForm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI/View/SampleDesigner/LayerForm.h b/GUI/View/SampleDesigner/LayerForm.h index 4db6a65f046..04448c8277f 100644 --- a/GUI/View/SampleDesigner/LayerForm.h +++ b/GUI/View/SampleDesigner/LayerForm.h @@ -24,7 +24,7 @@ class WidgetMoverButton; //! Form for editing a layer class LayerForm : public QGroupBox { - Q_OBJECT + Q_OBJECT // critically important ... even if we don't understand why public: LayerForm(QWidget* parent, LayerItem* layer, SampleEditorController* ec); -- GitLab From 5f537a326489440f6f20832728bdbfa453ca314a Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Sat, 11 Mar 2023 00:00:03 +0100 Subject: [PATCH 9/9] clang-format --- GUI/Support/Data/JobWorker.h | 3 +-- GUI/View/Mask/SizeHandleElement.h | 7 +++++-- GUI/View/Numeric/DoubleSpinBox.h | 16 ++++++++-------- GUI/View/Numeric/ScientificSpinBox.h | 5 ++--- GUI/View/PropertyEditor/CustomEditors.h | 3 +-- GUI/View/SampleDesigner/LayerForm.h | 3 +-- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/GUI/Support/Data/JobWorker.h b/GUI/Support/Data/JobWorker.h index dc223a70bc7..83fa1ada62b 100644 --- a/GUI/Support/Data/JobWorker.h +++ b/GUI/Support/Data/JobWorker.h @@ -27,8 +27,7 @@ class SimulationResult; class JobWorker : public QObject { Q_OBJECT // needed by qobject_cast -public: - JobWorker(QString identifier, ISimulation* simulation); + public : JobWorker(QString identifier, ISimulation* simulation); ~JobWorker(); QString identifier() const; diff --git a/GUI/View/Mask/SizeHandleElement.h b/GUI/View/Mask/SizeHandleElement.h index 34f7f873e35..b99fb7125c6 100644 --- a/GUI/View/Mask/SizeHandleElement.h +++ b/GUI/View/Mask/SizeHandleElement.h @@ -26,8 +26,11 @@ class SizeHandleElement : public QGraphicsObject { Q_OBJECT // needed by qobject_cast -public: - int type() const override { return MaskEditorHelper::SIZEHANDLE; } + public : int + type() const override + { + return MaskEditorHelper::SIZEHANDLE; + } enum EHandleLocation { NONE, diff --git a/GUI/View/Numeric/DoubleSpinBox.h b/GUI/View/Numeric/DoubleSpinBox.h index 050f313c7e3..87df628dbab 100644 --- a/GUI/View/Numeric/DoubleSpinBox.h +++ b/GUI/View/Numeric/DoubleSpinBox.h @@ -20,14 +20,14 @@ //! SpinBox for DoubleProperties, supporting units. class DoubleSpinBox : public QDoubleSpinBox { Q_OBJECT // required by qobject_cast (called via FormLayouter::widgetAt) -public: - //! Create a DoubleSpinBox with the information found in a DoubleProperty. - //! - //! The spin box will be fully initialized (tooltip, limits, unit, current value, size policy). - //! Furthermore, the spin box will prohibit accidental changes by the mouse wheel. Otherwise it - //! would be dangerous if the spin box is on a scrollable form - unintended and unnoticed - //! changes would take place when just scrolling through the form. - DoubleSpinBox(DoubleProperty& d, bool easyScrollable = false, QWidget* parent = nullptr); + public : + //! Create a DoubleSpinBox with the information found in a DoubleProperty. + //! + //! The spin box will be fully initialized (tooltip, limits, unit, current value, size + //! policy). Furthermore, the spin box will prohibit accidental changes by the mouse wheel. + //! Otherwise it would be dangerous if the spin box is on a scrollable form - unintended and + //! unnoticed changes would take place when just scrolling through the form. + DoubleSpinBox(DoubleProperty& d, bool easyScrollable = false, QWidget* parent = nullptr); //! Set a display unit. //! //! The caller has to make sure that the new display unit has a conversion to/from the contained diff --git a/GUI/View/Numeric/ScientificSpinBox.h b/GUI/View/Numeric/ScientificSpinBox.h index 28b7ae1a6e9..3c3a83d3c3a 100644 --- a/GUI/View/Numeric/ScientificSpinBox.h +++ b/GUI/View/Numeric/ScientificSpinBox.h @@ -19,9 +19,8 @@ class ScientificSpinBox : public QAbstractSpinBox { Q_OBJECT // needed by qobject_cast - Q_PROPERTY(double value MEMBER m_value READ value WRITE setValue NOTIFY valueChanged USER true) -public: - ScientificSpinBox(QWidget* parent = nullptr); + Q_PROPERTY(double value MEMBER m_value READ value WRITE setValue NOTIFY valueChanged + USER true) public : ScientificSpinBox(QWidget* parent = nullptr); ~ScientificSpinBox() override; double value() const; diff --git a/GUI/View/PropertyEditor/CustomEditors.h b/GUI/View/PropertyEditor/CustomEditors.h index 418a2668a3e..79fd91f708c 100644 --- a/GUI/View/PropertyEditor/CustomEditors.h +++ b/GUI/View/PropertyEditor/CustomEditors.h @@ -27,8 +27,7 @@ class RealLimits; class CustomEditor : public QWidget { Q_OBJECT // needed by qobject_cast -public: - explicit CustomEditor(QWidget* parent = nullptr) + public : explicit CustomEditor(QWidget* parent = nullptr) : QWidget(parent) { } diff --git a/GUI/View/SampleDesigner/LayerForm.h b/GUI/View/SampleDesigner/LayerForm.h index 04448c8277f..5ec3ec21584 100644 --- a/GUI/View/SampleDesigner/LayerForm.h +++ b/GUI/View/SampleDesigner/LayerForm.h @@ -25,8 +25,7 @@ class WidgetMoverButton; //! Form for editing a layer class LayerForm : public QGroupBox { Q_OBJECT // critically important ... even if we don't understand why -public: - LayerForm(QWidget* parent, LayerItem* layer, SampleEditorController* ec); + public : LayerForm(QWidget* parent, LayerItem* layer, SampleEditorController* ec); void enableStructureEditing(bool b); void updateLayerPositionDependentElements(); -- GitLab