SHAPER 9.16.0
CollectionPlugin_WidgetField.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef CollectionPlugin_WidgetField_H
21#define CollectionPlugin_WidgetField_H
22
23
24#include "CollectionPlugin.h"
25
26#include <ModuleBase_WidgetSelector.h>
27#include <ModuleBase_ViewerPrs.h>
28#include <ModelAPI_AttributeTables.h>
29
30#include <QList>
31#include <QStringList>
32#include <QStyledItemDelegate>
33
34
35class QWidget;
36class QComboBox;
37class QSpinBox;
38class QLabel;
39class QSlider;
40class QTableWidget;
41class QStackedWidget;
42class QPushButton;
43class QTableWidgetItem;
44class QLineEdit;
45
46
48{
49 Q_OBJECT
50public:
52
53 virtual QWidget* createEditor(QWidget* theParent,
54 const QStyleOptionViewItem & theOption,
55 const QModelIndex& theIndex) const;
56
57 ModelAPI_AttributeTables::ValueType dataType() const { return myType; }
58
59 void setDataType(ModelAPI_AttributeTables::ValueType theType) { myType = theType; }
60
61private slots:
62 void onEditItem(const QString& theText);
63
64private:
66};
67
68
69
75{
76 Q_OBJECT
77public:
79 ModuleBase_IWorkshop* theWorkshop,
80 const Config_WidgetAPI* theData);
81
83
86 virtual QList<QWidget*> getControls() const;
87
91 virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
92
94 virtual bool processEnter();
95
97 virtual void deactivate();
98
103 virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
104 const bool theToValidate);
105
106protected:
109 virtual bool storeValueCustom();
110
112 virtual bool restoreValueCustom();
113
116 virtual QIntList shapeTypes() const;
117
121 virtual bool eventFilter(QObject* theObject, QEvent* theEvent);
122
123 //virtual void showEvent(QShowEvent* theEvent);
124
128 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
129
130private slots:
133 void onNbCompChanged(int theVal);
134
136 void onAddStep();
137
139 void onRemoveStep();
140
143 void onStepMove(int theStep);
144
147 void onFieldTypeChanged(int theIdx);
148
152 void onTableEdited(int theRow, int theCol);
153
156 void onShapeTypeChanged(int theType);
157
161 void onFocusChanged(QWidget* theOld, QWidget* theNew);
162
166 void onRangeChanged(int theMin, int theMax);
167
168 void onColumnResize(int theIndex, int theOld, int theNew);
169
170private:
172 void clearData();
173
175 void appendStepControls();
176
178 void removeStepControls();
179
182 void updateHeaders(QTableWidget* theDataTbl) const;
183
186 int getSelectionType(const std::string& theStr) const;
187
190 std::string getSelectionType(int theType) const;
191
193 QTableWidgetItem* createDefaultItem() const;
194
197 QTableWidgetItem* createValueItem(ModelAPI_AttributeTables::Value& theVal) const;
198
199 QString getValueText(ModelAPI_AttributeTables::Value& theVal) const;
200
203 ModelAPI_AttributeTables::Value getValue(QString theStrVal) const;
204
206 QComboBox* myShapeTypeCombo;
207
209 QComboBox* myFieldTypeCombo;
210
212 QSpinBox* myNbComponentsSpn;
213
215 QLabel* myCurStepLbl;
216
218 QSlider* myStepSlider;
219
221 QList<QSpinBox*> myStampSpnList;
222
224 QList<QTableWidget*> myDataTblList;
225
227 QLabel* myMaxLbl;
228
230 QStackedWidget* myStepWgt;
231
233 QStringList myCompNamesList;
234
236 QPushButton* myRemoveBtn;
237
239 QLineEdit* myHeaderEditor;
240
242 int myEditIndex;
243
245 bool myIsTabEdit;
246
247 bool myActivation;
248
249 DataTableItemDelegate* myDelegate;
250};
251
252#endif
Definition: CollectionPlugin_WidgetField.h:75
virtual QIntList shapeTypes() const
Returns a list of possible shape types.
Definition: CollectionPlugin_WidgetField.cpp:653
virtual bool processEnter()
Returns true if the event is processed.
Definition: CollectionPlugin_WidgetField.cpp:992
virtual bool isValidSelectionCustom(const std::shared_ptr< ModuleBase_ViewerPrs > &theValue)
Checks the widget validity.
Definition: CollectionPlugin_WidgetField.cpp:821
virtual QList< QWidget * > getControls() const
Returns list of widget controls.
Definition: CollectionPlugin_WidgetField.cpp:447
virtual bool setSelection(QList< std::shared_ptr< ModuleBase_ViewerPrs > > &theValues, const bool theToValidate)
Set the given wrapped value to the current widget This value should be processed in the widget accord...
Definition: CollectionPlugin_WidgetField.cpp:828
virtual bool storeValueCustom()
Saves the internal parameters to the given feature.
Definition: CollectionPlugin_WidgetField.cpp:463
virtual void deactivate()
The methiod called when widget is deactivated.
Definition: CollectionPlugin_WidgetField.cpp:292
virtual bool restoreValueCustom()
Restore value from attribute data to the widget's control.
Definition: CollectionPlugin_WidgetField.cpp:505
virtual bool eventFilter(QObject *theObject, QEvent *theEvent)
Redefinition of virtual function.
Definition: CollectionPlugin_WidgetField.cpp:307
virtual QList< std::shared_ptr< ModuleBase_ViewerPrs > > getAttributeSelection() const
Return the attribute values wrapped in a list of viewer presentations.
Definition: CollectionPlugin_WidgetField.cpp:1039
Provides low-level API for WidgetFactory for reading xml definitions of widgets.
Definition: Config_WidgetAPI.h:46
Definition: CollectionPlugin_WidgetField.h:48
ValueType
Type of the value in the table.
Definition: ModelAPI_AttributeTables.h:42
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
Implementation of widget for selection.
Definition: ModuleBase_WidgetSelector.h:43
Definition: ModelAPI_AttributeTables.h:49