X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ModelWidget.h;h=2075a16dee145981c8b13b56695c504b2f7b9ce7;hb=1490e92974d2c0bdcdbecd6fa9388e31dccfa363;hp=35042a6458f6741b988ea49835e2a602c2e4328d;hpb=4049559747c32c5ec443cf3d60501bc64a17e58a;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 35042a645..2075a16de 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -8,7 +8,6 @@ #define MODULEBASE_MODELWIDGET_H #include -#include #include #include @@ -18,6 +17,8 @@ class Config_WidgetAPI; class ModuleBase_IWorkshop; +class ModuleBase_ViewerPrs; +class ModuleBase_WidgetValidator; class QKeyEvent; /**\class ModuleBase_ModelWidget @@ -39,12 +40,11 @@ Q_OBJECT ModifiedInViewer, /// modification performed by viewer events Reset }; /// the value is reset - /// Constructor + /// Constructor /// \param theParent the parent object /// \param theData the widget configuration. The attribute of the model widget is obtained from - /// \param theParentId is Id of a parent of the current attribute - ModuleBase_ModelWidget(QWidget* theParent, const Config_WidgetAPI* theData, - const std::string& theParentId); + /// \param theData a low-level API for reading xml definitions of widgets + ModuleBase_ModelWidget(QWidget* theParent, const Config_WidgetAPI* theData); /// Destructor virtual ~ModuleBase_ModelWidget() { @@ -94,7 +94,7 @@ Q_OBJECT /// Defines if it is supported to set the value in this widget /// By default it returns true - virtual bool canSetValue() const { return true; }; + virtual bool canAcceptFocus() const { return true; }; //! Returns the widget error, get it from the attribute validator and state of the widget //! If the feature is correct, it returns an empty value @@ -105,7 +105,7 @@ Q_OBJECT /// This value should be processed in the widget according to the needs /// \param theValues the wrapped selection values /// \param theToValidate the boolean value whether the value should be checked by filters - virtual bool setSelection(QList& theValues, + virtual bool setSelection(QList>& theValues, const bool theToValidate) { return false; @@ -113,12 +113,24 @@ Q_OBJECT /// Returns values which should be highlighted when the whidget is active /// \param theValues a list of presentations - virtual void getHighlighted(QList& theValues) {}; + virtual void getHighlighted(QList>& theValues) {}; + + /// Checks if the selection presentation is valid in widget + /// \param theValue a selected presentation in the view + /// \return a boolean value + virtual bool isValidSelectionCustom(const std::shared_ptr& theValue) { return true; } + + /// Returns widget validator, by default it is NULL. To be created in a child if necessary + ModuleBase_WidgetValidator* widgetValidator() { return myWidgetValidator; } /// Restore value from attribute data to the widget's control. Emits signals before and after store /// \return True in success bool restoreValue(); + /// Saves the internal parameters to the given feature. Emits signals before and after store + /// \return True in success + bool storeValue(); + /// Set focus to the first control of the current widget. The focus policy of the control is checked. /// If the widget has the NonFocus focus policy, it is skipped. /// \return the state whether the widget can accept the focus @@ -159,13 +171,6 @@ Q_OBJECT return myAttributeID; } - /// Returns the parent of the attribute - /// \returns the string value - std::string parentID() const - { - return myParentId; - } - /// \return Current feature FeaturePtr feature() const { @@ -178,7 +183,7 @@ Q_OBJECT void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false); /// Editing mode depends on mode of current operation. This value is defined by it. - void setEditingMode(bool isEditing) { myIsEditing = isEditing; } + virtual void setEditingMode(bool isEditing) { myIsEditing = isEditing; } /// \return Current Editing mode bool isEditingMode() const { return myIsEditing; } @@ -197,6 +202,10 @@ Q_OBJECT /// \param theObj is object for moving static void moveObject(ObjectPtr theObj); + /// Sends a message about block/unblock viewer updating + /// \param theValue a boolean value + static void blockUpdateViewer(const bool theValue); + signals: /// The signal about widget values are to be changed void beforeValuesChanged(); @@ -218,7 +227,8 @@ signals: void keyReleased(QObject* theObject, QKeyEvent* theEvent); /// The signal is emitted if the enter is clicked in the control of the widget - void enterClicked(); + /// \param theObject a sender of the event + void enterClicked(QObject* theObject); /// The signal about the widget is get focus /// \param theWidget the model base widget @@ -257,10 +267,6 @@ protected: /// or store the control value to the feature virtual void initializeValueByActivate(); - /// Saves the internal parameters to the given feature. Emits signals before and after store - /// \return True in success - bool storeValue(); - /// Saves the internal parameters to the given feature /// \return True in success virtual bool storeValueCustom() const = 0; @@ -275,10 +281,6 @@ protected: /// The method called when widget is activated virtual void activateCustom() {}; - /// Sends a message about block/unblock viewer updating - /// \param theValue a boolean value - static void blockUpdateViewer(const bool theValue); - protected slots: /// Processing of values changed in model widget by store the current value to the feature void onWidgetValuesChanged(); @@ -287,13 +289,11 @@ protected slots: void onWidgetValuesModified(); protected: + ModuleBase_WidgetValidator* myWidgetValidator; /// own validator, by default it is zero /// The attribute name of the model feature std::string myAttributeID; - /// Name of parent - std::string myParentId; - /// A feature which is processing by active operation FeaturePtr myFeature; @@ -321,8 +321,6 @@ private: bool myUseReset; /// blocked flag of modification of the value state bool myIsValueStateBlocked; - - friend class ModuleBase_OperationFeature; // to call storeValue() by commit if value state is ModifiedInPP }; #endif