Config_AttributeMessage::Config_AttributeMessage(const Events_ID theId, const void* theParent)
: Events_Message(theId, theParent)
{
- myAttributeId = ""; // Attribute unique id
- myFeatureId = ""; // Feature unique id
+ myAttributeId = std::string(); // Attribute unique id
+ myFeatureId = std::string(); // Feature unique id
myIsObligatory = true;
myIsConcealment = false;
+ myCaseId = std::string();
}
Config_AttributeMessage::~Config_AttributeMessage()
{
this->myIsObligatory = theObligatory;
}
+
+const std::string& Config_AttributeMessage::caseId() const
+{
+ return myCaseId;
+}
+
+void Config_AttributeMessage::setCaseId(const std::string& theId)
+{
+ this->myCaseId = theId;
+}
std::string myFeatureId; ///< Attribute's feature's unique id
bool myIsObligatory; ///< Required to be set by user, else it's feature is invalid.
bool myIsConcealment; ///< If true, conceals features used as input
+ std::string myCaseId; ///< Attribute's case's id, if it placed inside a paged containers
public:
/// Same event as Config_FeatureMessage::MODEL_EVENT()
CONFIG_EXPORT bool isObligatory() const;
/// Returns true if attribute should conceal input features
CONFIG_EXPORT bool isConcealment() const;
+ /// Returns id of a case which contain the attribute
+ CONFIG_EXPORT const std::string& caseId() const;
/// Set attribute's unique id
CONFIG_EXPORT void setAttributeId(const std::string& theId);
/// Set attribute's feature's unique id
CONFIG_EXPORT void setFeatureId(const std::string& id);
- /// Returns attribute's concealment state
+ /// Set attribute's concealment state
CONFIG_EXPORT void setConcealment(bool isConcealment);
- /// Returns attribute's obligatory state
+ /// Set attribute's obligatory state
CONFIG_EXPORT void setObligatory(bool isObligatory);
+ /// Set attribute's case
+ CONFIG_EXPORT void setCaseId(const std::string& id);
+
};
#endif // ATTRIBUTE_MESSAGE_H
\r
bool isNode(xmlNodePtr theNode, const char* theNodeName, ...)\r
{\r
- bool result = false;\r
const xmlChar* aName = theNode->name;\r
if (!aName || !isElementNode(theNode)) {\r
return false;\r
return false;\r
}\r
\r
+bool isAttributeNode(xmlNodePtr theNode)\r
+{\r
+ if(!isElementNode(theNode))\r
+ return false;\r
+ // it's parent is "feature" or "source" or page ("case" or "box")\r
+ if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, \r
+ WDG_TOOLBOX_BOX, WDG_SWITCH_CASE, NULL))\r
+ return false;\r
+\r
+ //it should not be a "source" or a "validator" node\r
+ bool isLogical = isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NODE_SELFILTER, NULL);\r
+ bool isPagedContainer = isNode(theNode, WDG_TOOLBOX, WDG_TOOLBOX_BOX,\r
+ WDG_SWITCH, WDG_SWITCH_CASE, NULL);\r
+ return !isLogical && !isPagedContainer;\r
+}\r
+\r
bool isWidgetNode(xmlNodePtr theNode)\r
{\r
if(!isElementNode(theNode))\r
return false;\r
// it's parent is "feature" or "source"\r
- xmlNodePtr aParentNode = theNode->parent;\r
- if(!isNode(aParentNode, NODE_FEATURE, NODE_SOURCE, NULL))\r
+ if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, \r
+ WDG_TOOLBOX_BOX, WDG_SWITCH_CASE, NULL))\r
return false;\r
\r
//it should not be a "source" or a "validator" node\r
return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NODE_SELFILTER, NULL);\r
}\r
\r
+// widget api?\r
+bool isCaseNode(xmlNodePtr theNode)\r
+{\r
+ if(!isElementNode(theNode))\r
+ return false;\r
+\r
+ return isNode(theNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL);\r
+}\r
+\r
bool hasChild(xmlNodePtr theNode)\r
{\r
xmlNodePtr aNode = theNode->children;\r
return false;\r
}\r
\r
+bool hasParent(xmlNodePtr theNode)\r
+{\r
+ xmlNodePtr aNode = theNode->parent;\r
+ if (!aNode) {\r
+ return false;\r
+ }\r
+ for (; aNode; aNode = aNode->next) {\r
+ if (isElementNode(theNode)) {\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+}\r
+\r
+bool hasParent(xmlNodePtr theNode, const char* theNodeName, ...)\r
+{\r
+ if (!hasParent(theNode)) {\r
+ return false; // have no parents at all\r
+ }\r
+ xmlNodePtr aNode = theNode->parent;\r
+ const xmlChar* aName = aNode->name;\r
+ if (!aName || !isElementNode(aNode)) {\r
+ return false;\r
+ }\r
+ if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) {\r
+ return true;\r
+ }\r
+ va_list args; // define argument list variable\r
+ va_start(args, theNodeName); // init list; point to last defined argument\r
+ while (true) {\r
+ char *anArg = va_arg (args, char*); // get next argument\r
+ if (anArg == NULL)\r
+ break;\r
+ if (!xmlStrcmp(aName, (const xmlChar *) anArg)) {\r
+ va_end(args); // cleanup the system stack\r
+ return true;\r
+ }\r
+ }\r
+ va_end(args); // cleanup the system stack\r
+ return false;\r
+}\r
+\r
bool getParametersInfo(xmlNodePtr theNode, std::string& outPropertyId,\r
std::list<std::string>& outValidatorParameters)\r
{\r
CONFIG_EXPORT bool isNode(xmlNodePtr theNode, const char* theNodeName, ...);
/*!
- * Checks is the given node is attribute (widget) node.
+ * Checks if the given node is attribute node.
+ * Attribute node represents a widget, that is able to store/restore
+ * values from the model. Actually it's every widget, displayed
+ * in the XGUI_PropertyPanel, except paged containers (toolbox, switch/case).
+ */
+CONFIG_EXPORT bool isAttributeNode(xmlNodePtr theNode);
+
+/*!
+ * Checks if the given node is widget node.
+ * Widget nodes are attribute node + paged containers nodes.
*/
CONFIG_EXPORT bool isWidgetNode(xmlNodePtr theNode);
+CONFIG_EXPORT bool isCaseNode(xmlNodePtr theNode);
+
/*!
* Every xml node has child. Even if there is no explicit
* child nodes libxml gives the "Text node" as child.
*/
CONFIG_EXPORT bool hasChild(xmlNodePtr theNode);
+
+/*!
+ * Checks if the given node has a valid parent.
+ */
+CONFIG_EXPORT bool hasParent(xmlNodePtr theNode);
+
+/*!
+ * Checks if the given node has a valid parent with any of the given node names.
+ */
+CONFIG_EXPORT bool hasParent(xmlNodePtr theNode, const char* theNodeName, ...);
+
/*!
* Returns named property for an id node as std::string and the parameters of the node.
*/
} else if (isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL)) {
storeAttribute(theNode, _ID);
storeAttribute(theNode, WORKBENCH_DOC);
- } else if (myIsProcessWidgets && isWidgetNode(theNode)) {
- std::shared_ptr<Config_AttributeMessage> aMessage(new Config_AttributeMessage(aMenuItemEvent, this));
- aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID));
- std::string anAttributeID = getProperty(theNode, _ID);
- if (!anAttributeID.empty()) {
- aMessage->setAttributeId(anAttributeID);
- aMessage->setObligatory(getBooleanAttribute(theNode, ATTR_OBLIGATORY, true));
- aMessage->setConcealment(getBooleanAttribute(theNode, ATTR_CONCEALMENT, false));
- Events_Loop::loop()->send(aMessage);
+ } else if (myIsProcessWidgets) {
+ // widgets, like shape_selector or containers, like toolbox
+ if (isAttributeNode(theNode)) {
+ std::shared_ptr<Config_AttributeMessage> aMessage(new Config_AttributeMessage(aMenuItemEvent, this));
+ aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID));
+ std::string anAttributeID = getProperty(theNode, _ID);
+ if (!anAttributeID.empty()) {
+ aMessage->setAttributeId(anAttributeID);
+ aMessage->setObligatory(getBooleanAttribute(theNode, ATTR_OBLIGATORY, true));
+ aMessage->setConcealment(getBooleanAttribute(theNode, ATTR_CONCEALMENT, false));
+ // nested "paged" widgets are not allowed, this issue may be resolved here:
+ if (hasParent(theNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL)) {
+ const char* kWdgCase = hasParent(theNode, WDG_SWITCH_CASE, NULL)
+ ? WDG_SWITCH_CASE
+ : WDG_TOOLBOX_BOX;
+ aMessage->setCaseId(restoreAttribute(kWdgCase, _ID));
+ }
+ Events_Loop::loop()->send(aMessage);
+ }
+ // container pages, like "case" or "box"
+ } else if (isCaseNode(theNode)) {
+ storeAttribute(theNode, _ID); // save case:caseId (or box:boxId)
}
}
//Process SOURCE, VALIDATOR nodes.
Config_XMLReader::processNode(theNode);
}
+void Config_FeatureReader::cleanup(xmlNodePtr theNode)
+{
+ if (isCaseNode(theNode)) {
+ // cleanup id of cases when leave case node
+ cleanupAttribute(theNode, _ID);
+ }
+}
+
bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
{
bool result = isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
if(!result && myIsProcessWidgets) {
- result = isNode(theNode, NODE_FEATURE, NULL);
+ result = isNode(theNode, NODE_FEATURE,
+ WDG_TOOLBOX, WDG_TOOLBOX_BOX,
+ WDG_SWITCH, WDG_SWITCH_CASE, NULL);
}
return result;
}
}
return result;
}
+
+bool Config_FeatureReader::cleanupAttribute(xmlNodePtr theNode,
+ const char* theNodeAttribute)
+{
+ return cleanupAttribute(getNodeName(theNode).c_str(), theNodeAttribute);
+}
+
+bool Config_FeatureReader::cleanupAttribute(const char* theNodeName,
+ const char* theNodeAttribute)
+{
+ std::string aKey = std::string(theNodeName) + ":" + std::string(theNodeAttribute);
+ bool result = false;
+ std::map<std::string, std::string>::iterator anEntry = myParentAttributes.find(aKey);
+ if( anEntry != myParentAttributes.end()) {
+ myParentAttributes.erase(anEntry);
+ result = true;
+ }
+ return result;
+}
+
protected:
/// Overloaded method. Defines how to process each node
virtual void processNode(xmlNodePtr aNode);
+
+ /// Overloaded method. Clears attribute cache on extit from attribute's node
+ virtual void cleanup(xmlNodePtr aNode);
+
/// Overloaded method. Defines if the given node should be parsed recursively
virtual bool processChildren(xmlNodePtr aNode);
/// Restores an attribute from internal map.
std::string restoreAttribute(const char* theNodeName, const char* theNodeAttribute);
+ bool cleanupAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+ bool cleanupAttribute(const char* theNodeName, const char* theNodeAttribute);
+
private:
/// A map to store all parent's attributes.
/// The key has from "Node_Name:Node_Attribute"
}
}
+void Config_XMLReader::cleanup(xmlNodePtr)
+{
+ // do nothing;
+}
+
bool Config_XMLReader::processChildren(xmlNodePtr aNode)
{
return true;
if (processChildren(aNode)) {
readRecursively(aNode);
}
+ cleanup(aNode);
}
}
* "selection_filter" nodes.
*/
virtual void processNode(xmlNodePtr aNode);
+
+ /*!
+ * This method gives an ability to finalize processing of a node,
+ * when reader is about to leave the node (node and all it's children are processed)
+ */
+ virtual void cleanup(xmlNodePtr aNode);
/*!
* \brief Defines which nodes should be processed recursively. Virtual.
* The default impl is to read all nodes.
<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
<source>
- <shape_selector id="firstPoint"
- label="First point"
- icon=":icons/point.png"
- tooltip="Select a first point"
- shape_types="vertex">
- <selection_filter id="NoConstructionSubShapesFilter"/>
- </shape_selector>
- <shape_selector id="secondPoint"
- label="Second point"
- icon=":icons/point.png"
- tooltip="Select a second point"
- shape_types="vertex">
- <selection_filter id="NoConstructionSubShapesFilter"/>
- <validator id="PartSet_DifferentShapes"/>
- </shape_selector>
+ <toolbox>
+ <box id="AxisByPointsCase" title="By two points">
+ <shape_selector id="firstPoint"
+ label="First point"
+ icon=":icons/point.png"
+ tooltip="Select a first point"
+ shape_types="vertex">
+ <selection_filter id="NoConstructionSubShapesFilter"/>
+ </shape_selector>
+ <shape_selector id="secondPoint"
+ label="Second point"
+ icon=":icons/point.png"
+ tooltip="Select a second point"
+ shape_types="vertex">
+ <selection_filter id="NoConstructionSubShapesFilter"/>
+ <validator id="PartSet_DifferentShapes"/>
+ </shape_selector>
+ </box>
+ <box id="AxisByCylindricalFaceCase" title="As axis of cylindrical face">
+ <shape_selector id="main_object"
+ label="Main object"
+ icon=":icons/circle.png"
+ tooltip="Select a cylindrical object"
+ shape_types="face solid shell">
+ </shape_selector>
+ </box>
+ </toolbox>
+
</source>
#include <Events_Loop.h>
#include <QEvent>
-#include <QWidget>
#include <QGraphicsDropShadowEffect>
#include <QColor>
#include <QLabel>
-ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_WidgetAPI* theData,
+ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
+ const Config_WidgetAPI* theData,
const std::string& theParentId)
- : QObject(theParent),
- myParentId(theParentId)
+ : QWidget(theParent),
+ myParentId(theParentId),
+ myIsEditing(false)
{
myDefaultValue = theData->getProperty(ATTR_DEFAULT);
myIsComputedDefault = theData->getProperty(ATTR_DEFAULT) == DOUBLE_WDG_DEFAULT_COMPUTED;
#include <ModelAPI_Feature.h>
-#include <QObject>
+#include <QWidget>
#include <memory>
* Every widget are able to save/restore data from the model and/or to contain other widgets.
*
*/
-class MODULEBASE_EXPORT ModuleBase_ModelWidget : public QObject
+class MODULEBASE_EXPORT ModuleBase_ModelWidget : public QWidget
{
Q_OBJECT
public:
/// The methiod called when widget is deactivated
virtual void deactivate() {}
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- virtual QWidget* getControl() const = 0;
-
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const = 0;
{
if(!theLayout)
return;
- theLayout->setContentsMargins(2, 5, 5, 2);
+ theLayout->setContentsMargins(2, 5, 2, 5);
theLayout->setSpacing(4);
}
{
}
-QWidget* ModuleBase_WidgetBoolValue::getControl() const
-{
- return myCheckBox;
-}
-
bool ModuleBase_WidgetBoolValue::storeValueCustom() const
{
DataPtr aData = myFeature->data();
virtual QList<QWidget*> getControls() const;
- QWidget* getControl() const;
-
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
- myContainer = new QWidget(theParent);
- QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
+ QHBoxLayout* aLayout = new QHBoxLayout(this);
ModuleBase_Tools::adjustMargins(aLayout);
QString aLabelText = QString::fromStdString(theData->widgetLabel());
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
- myLabel = new QLabel(aLabelText, myContainer);
+ myLabel = new QLabel(aLabelText, this);
if (!aLabelIcon.isEmpty())
myLabel->setPixmap(QPixmap(aLabelIcon));
aLayout->addWidget(myLabel);
- myCombo = new QComboBox(myContainer);
+ myCombo = new QComboBox(this);
aLayout->addWidget(myCombo, 1);
std::string aTypes = theData->getProperty("string_list");
virtual bool focusTo();
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- QWidget* getControl() const
- {
- return myContainer;
- }
-
/// Returns list of widget controls
/// \return a controls list
virtual QList<QWidget*> getControls() const;
void onCurrentIndexChanged(int theIndex);
private:
- /// Container widget
- QWidget* myContainer;
-
/// The label
QLabel* myLabel;
#include <ModelAPI_Events.h>
#include <QWidget>
-#include <QLayout>
+#include <QFormLayout>
#include <QLabel>
#include <QEvent>
#include <QTimer>
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
- myContainer = new QWidget(theParent);
- QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
+ QFormLayout* aControlLay = new QFormLayout(this);
ModuleBase_Tools::adjustMargins(aControlLay);
QString aLabelText = QString::fromStdString(theData->widgetLabel());
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
- myLabel = new QLabel(aLabelText, myContainer);
+ myLabel = new QLabel(aLabelText, this);
if (!aLabelIcon.isEmpty())
myLabel->setPixmap(QPixmap(aLabelIcon));
- aControlLay->addWidget(myLabel);
- mySpinBox = new ModuleBase_DoubleSpinBox(myContainer);
+ mySpinBox = new ModuleBase_DoubleSpinBox(this);
QString anObjName = QString::fromStdString(attributeID());
mySpinBox->setObjectName(anObjName);
QString aTTip = QString::fromStdString(theData->widgetTooltip());
mySpinBox->setToolTip(aTTip);
- aControlLay->addWidget(mySpinBox);
- aControlLay->setStretch(1, 1);
-
+ aControlLay->addRow(myLabel, mySpinBox);
connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
}
/// \return a control list
virtual QList<QWidget*> getControls() const;
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- QWidget* getControl() const
- {
- return myContainer;
- }
-
public slots:
// Delayed value chnged: when user starts typing something,
// it gives him a 0,5 second to finish typing, when sends valueChnaged() signal
virtual bool storeValueCustom() const;
protected:
- /// Container for thw widget controls
- QWidget* myContainer;
-
/// Label of the widget
QLabel* myLabel;
return;
QVBoxLayout* aWidgetLay = new QVBoxLayout(theParent);
+ bool isStretchLayout = false;
do { //Iterate over each node
std::string aWdgType = myWidgetApi->widgetType();
//Create a widget (doublevalue, groupbox, toolbox, etc.
do {
QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
QWidget* aPage = new QWidget(aWidget);
- ModuleBase_Tools::adjustMargins(aPage);
createWidget(aPage);
+ ModuleBase_Tools::adjustMargins(aPage);
if (aWdgType == WDG_SWITCH) {
ModuleBase_WidgetSwitch* aSwitch = qobject_cast<ModuleBase_WidgetSwitch*>(aWidget);
aSwitch->addPage(aPage, aPageName);
QToolBox* aToolbox = qobject_cast<QToolBox*>(aWidget);
aToolbox->addItem(aPage, aPageName);
}
+
} while (myWidgetApi->toNextWidget());
}
+ if (aWidget && !isStretchLayout) {
+ isStretchLayout = !hasExpandingControls(aWidget);
+ }
} while (myWidgetApi->toNextWidget());
+ if (isStretchLayout) {
+ aWidgetLay->addStretch(1);
+ }
theParent->setLayout(aWidgetLay);
}
-
-QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent)
+bool ModuleBase_WidgetFactory::hasExpandingControls(QWidget* theParent)
{
- ModuleBase_WidgetLabel* aWgt =
- new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId);
- myModelWidgets.append(aWgt);
- return aWgt->getControl();
+ bool result = false;
+ QList<QWidget *> aListToCheck;
+ aListToCheck << theParent;
+ ModuleBase_ModelWidget* aModelWidget = qobject_cast<ModuleBase_ModelWidget*>(theParent);
+ if(aModelWidget) {
+ aListToCheck << aModelWidget->getControls();
+ }
+ foreach(QWidget* eachWidget, aListToCheck) {
+ QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
+ if(aVPolicy & QSizePolicy::ExpandFlag) {
+ result = true;
+ }
+ }
+ return result;
}
-
QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType,
QWidget* theParent)
{
} else if (theType == WDG_BOOLVALUE) {
result = booleanControl(theParent);
- //} else if (theType == WDG_FEATURE_SELECTOR) {
- // result = featureSelectorControl(theParent);
-
- //} else if (theType == WDG_FEATURE_OR_ATTRIBUTE_SELECTOR) {
- // result = featureOrAttributeSelectorControl(theParent);
-
} else if (theType == WDG_DOUBLEVALUE_EDITOR) {
result = doubleValueEditor(theParent);
result = aGroupBox;
} else if (theType == WDG_TOOLBOX) {
result = new QToolBox(theParent);
+ // Dark-grey rounded tabs with button-like border #and bold font
+ QString css = "QToolBox::tab{background-color:#c8c8c8;"
+ "border-radius:5px;"
+ "border:1px inset;"
+ //"font-weight:700;"
+ "border-color:#fff #505050 #505050 #fff;}";
+ result->setStyleSheet(css);
+ // default vertical size policy is preferred
+ QSizePolicy aSizePolicy = result->sizePolicy();
+ aSizePolicy.setVerticalPolicy(QSizePolicy::MinimumExpanding);
+ result->setSizePolicy(aSizePolicy);
} else if (theType == WDG_SWITCH) {
result = new ModuleBase_WidgetSwitch(theParent);
} else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) {
+ // Do nothing for "box" and "case"
result = NULL;
}
#ifdef _DEBUG
return result;
}
+QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent)
+{
+ ModuleBase_WidgetLabel* aWgt =
+ new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId);
+ myModelWidgets.append(aWgt);
+ return aWgt;
+}
+
QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent)
{
ModuleBase_WidgetDoubleValue* aDblWgt =
new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aDblWgt);
- return aDblWgt->getControl();
+ return aDblWgt;
}
QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent)
ModuleBase_WidgetEditor* aWidget =
new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aWidget);
- return aWidget->getControl();
+ return aWidget;
}
QWidget* ModuleBase_WidgetFactory::shapeSelectorControl(QWidget* theParent)
ModuleBase_WidgetShapeSelector* aSelector =
new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi, myParentId);
myModelWidgets.append(aSelector);
- return aSelector->getControl();
+ return aSelector;
}
QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
ModuleBase_WidgetBoolValue* aBoolWgt =
new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aBoolWgt);
- return aBoolWgt->getControl();
+ return aBoolWgt;
}
QWidget* ModuleBase_WidgetFactory::fileSelectorControl(QWidget* theParent)
ModuleBase_WidgetFileSelector* aFileSelectorWgt =
new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aFileSelectorWgt);
- return aFileSelectorWgt->getControl();
+ return aFileSelectorWgt;
}
QWidget* ModuleBase_WidgetFactory::choiceControl(QWidget* theParent)
ModuleBase_WidgetChoice* aChoiceWgt =
new ModuleBase_WidgetChoice(theParent, myWidgetApi,myParentId);
myModelWidgets.append(aChoiceWgt);
- return aChoiceWgt->getControl();
+ return aChoiceWgt;
}
QWidget* ModuleBase_WidgetFactory::lineEditControl(QWidget* theParent)
ModuleBase_WidgetLineEdit* aLineEditWgt =
new ModuleBase_WidgetLineEdit(theParent, myWidgetApi,myParentId);
myModelWidgets.append(aLineEditWgt);
- return aLineEditWgt->getControl();
+ return aLineEditWgt;
}
QWidget* ModuleBase_WidgetFactory::multiSelectorControl(QWidget* theParent)
ModuleBase_WidgetMultiSelector* aMultiselectorWgt =
new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi,myParentId);
myModelWidgets.append(aMultiselectorWgt);
- return aMultiselectorWgt->getControl();
+ return aMultiselectorWgt;
}
QString ModuleBase_WidgetFactory::qs(const std::string& theStdString)
/// \param theParent a parent widget
void createWidget(QWidget* theParent);
+
/// Returns list of model widgets
QList<ModuleBase_ModelWidget*> getModelWidgets() const
{
}
protected:
+ /// check if ModuleBase_Widget has expandable widgets in getControls
+ bool hasExpandingControls(QWidget* theParent);
/// Create widget by its type
/// \param theType a type
/// \param theParent a parent widget
myTitle = QString::fromStdString(theData->getProperty("title"));
myDefaultPath = QString::fromStdString(theData->getProperty("path"));
- myMainWidget = new QWidget(theParent);
- QGridLayout* aMainLay = new QGridLayout(myMainWidget);
+ QGridLayout* aMainLay = new QGridLayout(this);
ModuleBase_Tools::adjustMargins(aMainLay);
- QLabel* aTitleLabel = new QLabel(myTitle, myMainWidget);
+ QLabel* aTitleLabel = new QLabel(myTitle, this);
aTitleLabel->setIndent(1);
aMainLay->addWidget(aTitleLabel, 0, 0);
- myPathField = new QLineEdit(myMainWidget);
+ myPathField = new QLineEdit(this);
aMainLay->addWidget(myPathField, 1, 0);
- QPushButton* aSelectPathBtn = new QPushButton("...", myMainWidget);
+ QPushButton* aSelectPathBtn = new QPushButton("...", this);
aSelectPathBtn->setToolTip(tr("Select file..."));
aSelectPathBtn->setMaximumWidth(20);
aSelectPathBtn->setMaximumHeight(20);
aMainLay->setColumnStretch(0, 1);
myPathField->setMinimumHeight(20);
aMainLay->setHorizontalSpacing(1);
- myMainWidget->setLayout(aMainLay);
+ this->setLayout(aMainLay);
connect(myPathField, SIGNAL(textChanged(const QString&)),
this, SLOT(onPathChanged()));
return true;
}
-QWidget* ModuleBase_WidgetFileSelector::getControl() const
-{
- return myMainWidget;
-}
-
QList<QWidget*> ModuleBase_WidgetFileSelector::getControls() const
{
QList<QWidget*> result;
- //QPushButton * aButton = myMainWidget->findChild<QPushButton *>();
+ //QPushButton * aButton = this->findChild<QPushButton *>();
//result << aButton;
result << myPathField;
return result;
void ModuleBase_WidgetFileSelector::onPathSelectionBtn()
{
QString aFilter = formatsString();
- QString aFileName = QFileDialog::getOpenFileName(myMainWidget, myTitle, myDefaultPath, aFilter);
+ QString aFileName = QFileDialog::getOpenFileName(this, myTitle, myDefaultPath, aFilter);
if (!aFileName.isEmpty()) {
myPathField->setText(aFileName);
}
virtual bool restoreValue();
- QWidget* getControl() const;
-
virtual QList<QWidget*> getControls() const;
/// Returns true if a file on the current path in the line edit
/// A control for path input
QLineEdit* myPathField;
- /// Container
- QWidget* myMainWidget;
-
/// A title of open file dialog box
QString myTitle;
#include "ModuleBase_WidgetLabel.h"
#include <Config_WidgetAPI.h>
+#include <ModuleBase_Tools.h>
#include <QLabel>
+#include <QVBoxLayout>
ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent,
- const Config_WidgetAPI* theData,
- const std::string& theParentId)
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
QString aText = QString::fromStdString(theData->getProperty("title"));
myLabel = new QLabel(aText, theParent);
myLabel->setWordWrap(true);
myLabel->setIndent(5);
+ myLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
+ QVBoxLayout* aLayout = new QVBoxLayout(this);
+ ModuleBase_Tools::zeroMargins(aLayout);
+ aLayout->addWidget(myLabel);
+ setLayout(aLayout);
}
ModuleBase_WidgetLabel::~ModuleBase_WidgetLabel()
return QList<QWidget*>();
}
-QWidget* ModuleBase_WidgetLabel::getControl() const
-{
- return myLabel;
-}
virtual QList<QWidget*> getControls() const;
- QWidget* getControl() const;
-
/// This control doesn't accept focus
virtual bool focusTo() { return false; }
QLabel* myLabel;
};
-#endif
\ No newline at end of file
+#endif
#include <Config_WidgetAPI.h>
-#include <QHBoxLayout>
+#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QObject>
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
- myMainWidget = new QWidget(theParent);
- QHBoxLayout* aMainLay = new QHBoxLayout(myMainWidget);
+ QFormLayout* aMainLay = new QFormLayout(this);
ModuleBase_Tools::adjustMargins(aMainLay);
QString aTitle = QString::fromStdString(theData->widgetLabel());
- QLabel* aTitleLabel = new QLabel(aTitle, myMainWidget);
- aMainLay->addWidget(aTitleLabel);
- myLineEdit = new QLineEdit(myMainWidget);
- aMainLay->addWidget(myLineEdit);
+ myLineEdit = new QLineEdit(this);
myLineEdit->setMinimumHeight(20);
- myMainWidget->setLayout(aMainLay);
+ aMainLay->addRow(aTitle, myLineEdit);
+ this->setLayout(aMainLay);
connect(myLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged()));
}
return true;
}
-QWidget* ModuleBase_WidgetLineEdit::getControl() const
-{
- return myMainWidget;
-}
-
QList<QWidget*> ModuleBase_WidgetLineEdit::getControls() const
{
QList<QWidget*> result;
virtual bool restoreValue();
- QWidget* getControl() const;
-
virtual QList<QWidget*> getControls() const;
public slots:
private:
/// A line edit control
QLineEdit* myLineEdit;
-
- /// A container widget
- QWidget* myMainWidget;
};
#endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */
: ModuleBase_ModelWidget(theParent, theData, theParentId),
myWorkshop(theWorkshop), myIsActive(false)
{
- myMainWidget = new QWidget(theParent);
- QGridLayout* aMainLay = new QGridLayout(myMainWidget);
+ QGridLayout* aMainLay = new QGridLayout(this);
ModuleBase_Tools::adjustMargins(aMainLay);
- QLabel* aTypeLabel = new QLabel(tr("Type"), myMainWidget);
+ QLabel* aTypeLabel = new QLabel(tr("Type"), this);
aMainLay->addWidget(aTypeLabel, 0, 0);
- myTypeCombo = new QComboBox(myMainWidget);
+ myTypeCombo = new QComboBox(this);
// There is no sence to paramerize list of types while we can not parametrize selection mode
QString aTypesStr("Vertices Edges Faces Solids");
QStringList aShapeTypes = aTypesStr.split(' ');
myTypeCombo->addItems(aShapeTypes);
aMainLay->addWidget(myTypeCombo, 0, 1);
- QLabel* aListLabel = new QLabel(tr("Selected objects:"), myMainWidget);
+ QLabel* aListLabel = new QLabel(tr("Selected objects:"), this);
aMainLay->addWidget(aListLabel, 1, 0, 1, -1);
- myListControl = new QListWidget(myMainWidget);
+ myListControl = new QListWidget(this);
aMainLay->addWidget(myListControl, 2, 0, 2, -1);
aMainLay->setRowStretch(2, 1);
- aMainLay->addWidget(new QLabel(myMainWidget));
+ aMainLay->addWidget(new QLabel(this)); //FIXME(sbh)???
aMainLay->setRowMinimumHeight(3, 20);
- myMainWidget->setLayout(aMainLay);
+ this->setLayout(aMainLay);
connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectionTypeChanged()));
myCopyAction = new QAction(QIcon(":pictures/copy.png"), tr("Copy"), this);
return false;
}
-//********************************************************************
-QWidget* ModuleBase_WidgetMultiSelector::getControl() const
-{
- return myMainWidget;
-}
-
//********************************************************************
QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
{
virtual bool restoreValue();
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- QWidget* getControl() const;
-
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const;
/// Combobox of types
QComboBox* myTypeCombo;
- /// Container
- QWidget* myMainWidget;
-
//TODO: Move into the base of selectors
ModuleBase_IWorkshop* myWorkshop;
#include <QEvent>
#include <QDockWidget>
#include <QApplication>
+#include <QFormLayout>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Shape.hxx>
: ModuleBase_ModelWidget(theParent, theData, theParentId),
myWorkshop(theWorkshop), myIsActive(false)
{
- myContainer = new QWidget(theParent);
- QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
+ QFormLayout* aLayout = new QFormLayout(this);
ModuleBase_Tools::adjustMargins(aLayout);
QString aLabelText = QString::fromStdString(theData->widgetLabel());
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
- myLabel = new QLabel(aLabelText, myContainer);
+ myLabel = new QLabel(aLabelText, this);
if (!aLabelIcon.isEmpty())
myLabel->setPixmap(QPixmap(aLabelIcon));
- aLayout->addWidget(myLabel);
QString aToolTip = QString::fromStdString(theData->widgetTooltip());
- myTextLine = new QLineEdit(myContainer);
+ myTextLine = new QLineEdit(this);
myTextLine->setReadOnly(true);
myTextLine->setToolTip(aToolTip);
myTextLine->installEventFilter(this);
- aLayout->addWidget(myTextLine, 1);
+ aLayout->addRow(myLabel, myTextLine);
std::string aTypes = theData->getProperty("shape_types");
myShapeTypes = QString(aTypes.c_str()).split(' ', QString::SkipEmptyParts);
//********************************************************************
void ModuleBase_WidgetShapeSelector::raisePanel() const
{
- QWidget* aParent = myContainer->parentWidget();
+ QWidget* aParent = this->parentWidget();
QWidget* aLastPanel = 0;
while (!aParent->inherits("QDockWidget")) {
aLastPanel = aParent;
}
}
return true;
-}
\ No newline at end of file
+}
/// Defines if it is supposed that the widget should interact with the viewer.
virtual bool isViewerSelector() { return true; }
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- QWidget* getControl() const
- {
- return myContainer;
- }
-
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const;
//----------- Class members -------------
protected:
-
- /// Container of the widget's control
- QWidget* myContainer;
-
/// Label of the widget
QLabel* myLabel;
{
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
XGUI_Workshop* aWorkshop = aConnector->workshop();
+ ModuleBase_ModelWidget* aWgt = NULL;
if (theType == "sketch-start-label") {
- PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
- aWgt->setWorkshop(aWorkshop);
- connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
+ PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
+ aLabelWgt->setWorkshop(aWorkshop);
+ connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
- theModelWidgets.append(aWgt);
- return aWgt->getControl();
-
+ aWgt = aLabelWgt;
} else if (theType == "sketch-2dpoint_selector") {
- PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
- aWgt->setWorkshop(aWorkshop);
- aWgt->setSketch(mySketchMgr->activeSketch());
-
- connect(aWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
-
- theModelWidgets.append(aWgt);
- return aWgt->getControl();
-
+ PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
+ aPointWgt->setWorkshop(aWorkshop);
+ aPointWgt->setSketch(mySketchMgr->activeSketch());
+ connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
+ aWgt = aPointWgt;
} if (theType == "point2ddistance") {
- PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
- aWgt->setWorkshop(aWorkshop);
- aWgt->setSketch(mySketchMgr->activeSketch());
-
- theModelWidgets.append(aWgt);
- return aWgt->getControl();
-
+ PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
+ aDistanceWgt->setWorkshop(aWorkshop);
+ aDistanceWgt->setSketch(mySketchMgr->activeSketch());
+ aWgt = aDistanceWgt;
} if (theType == "sketch_shape_selector") {
- PartSet_WidgetShapeSelector* aWgt =
+ PartSet_WidgetShapeSelector* aShapeSelectorWgt =
new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
- aWgt->setSketcher(mySketchMgr->activeSketch());
-
- theModelWidgets.append(aWgt);
- return aWgt->getControl();
-
+ aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
+ aWgt = aShapeSelectorWgt;
} if (theType == "sketch_constraint_shape_selector") {
- PartSet_WidgetConstraintShapeSelector* aWgt =
+ PartSet_WidgetConstraintShapeSelector* aConstraintShapeSelectorWgt =
new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
- aWgt->setSketcher(mySketchMgr->activeSketch());
-
+ aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
+ aWgt = aConstraintShapeSelectorWgt;
+ }
+ if(aWgt)
theModelWidgets.append(aWgt);
- return aWgt->getControl();
-
- } else
- return 0;
+ return aWgt;
}
void PartSet_Module::createActions()
connect(myYSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
}
+ QVBoxLayout* aLayout = new QVBoxLayout(this);
+ ModuleBase_Tools::zeroMargins(aLayout);
+ aLayout->addWidget(myGroupBox);
+ setLayout(aLayout);
}
void PartSet_WidgetPoint2D::reset()
return true;
}
-QWidget* PartSet_WidgetPoint2D::getControl() const
-{
- return myGroupBox;
-}
-
QList<QWidget*> PartSet_WidgetPoint2D::getControls() const
{
QList<QWidget*> aControls;
virtual bool restoreValue();
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- QWidget* getControl() const;
-
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const;
#include <ModuleBase_Operation.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomDataAPI_Point.h>
#include <QLabel>
#include <QTimer>
#include <QApplication>
+#include <QVBoxLayout>
PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
const Config_WidgetAPI* theData,
const std::string& theParentId)
- : ModuleBase_ModelWidget(theParent, theData, theParentId), myPreviewDisplayed(false)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId),
+ myPreviewDisplayed(false),
+ myWorkshop(NULL)
{
myText = QString::fromStdString(theData->getProperty("title"));
myLabel = new QLabel("", theParent);
mySelectionTimer = new QTimer(this);
connect(mySelectionTimer, SIGNAL(timeout()), SLOT(setSketchingMode()));
mySelectionTimer->setSingleShot(true);
+
+ QVBoxLayout* aLayout = new QVBoxLayout(this);
+ ModuleBase_Tools::zeroMargins(aLayout);
+ aLayout->addWidget(myLabel);
+ setLayout(aLayout);
}
PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel()
return QList<QWidget*>();
}
-QWidget* PartSet_WidgetSketchLabel::getControl() const
-{
- return myLabel;
-}
-
void PartSet_WidgetSketchLabel::onPlaneSelected()
{
XGUI_Selection* aSelection = myWorkshop->selector()->selection();
/// \return a control list
virtual QList<QWidget*> getControls() const;
- QWidget* getControl() const;
-
/// The methiod called when widget is deactivated
virtual void deactivate();
foreach(QString aId, nestedCommands(aFeatureId)) {
std::list<ModelAPI_Validator*> aValidators;
std::list<std::list<std::string> > anArguments;
- if (!anArguments.empty()) {
- std::list<std::string> firstArg = anArguments.front();
- }
aFactory->validators(aId.toStdString(), aValidators, anArguments);
std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
std::list<std::list<std::string> >::iterator aValidatorArgs = anArguments.begin();
#include <ModelAPI_Document.h>
#include <ModelAPI_Object.h>
+#include <ModuleBase_Tools.h>
+
#include <QLayout>
#include <QLabel>
#include <QLineEdit>
: QWidget(theParent)
{
QVBoxLayout* aLayout = new QVBoxLayout(this);
- aLayout->setContentsMargins(0, 0, 0, 0);
+ ModuleBase_Tools::zeroMargins(aLayout);
aLayout->setSpacing(0);
QFrame* aLabelWgt = new QFrame(this);
aLayout->addWidget(aLabelWgt);
QHBoxLayout* aLabelLay = new QHBoxLayout(aLabelWgt);
- aLabelLay->setContentsMargins(0, 0, 0, 0);
+ ModuleBase_Tools::zeroMargins(aLabelLay);
aLabelLay->setSpacing(0);
QLabel* aLbl = new QLabel(aLabelWgt);
#include <XGUI_ActionsMgr.h>
//#include <AppElements_Constants.h>
#include <ModuleBase_WidgetMultiSelector.h>
+#include <ModuleBase_Tools.h>
#include <QEvent>
#include <QFrame>
#include <QLayoutItem>
#include <QToolButton>
#include <QVBoxLayout>
-#include <QVBoxLayout>
+#include <QGridLayout>
#include <QWidget>
#include <QToolButton>
#include <QAction>
setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
QWidget* aContent = new QWidget(this);
- myMainLayout = new QVBoxLayout(aContent);
+ myMainLayout = new QGridLayout(aContent);
+ const int kPanelColumn = 0;
+ int aPanelRow = 0;
myMainLayout->setContentsMargins(3, 3, 3, 3);
this->setWidget(aContent);
QFrame* aFrm = new QFrame(aContent);
- aFrm->setFrameStyle(QFrame::Sunken);
+ aFrm->setFrameStyle(QFrame::Raised);
aFrm->setFrameShape(QFrame::Panel);
QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
- aBtnLay->setContentsMargins(0, 0, 0, 0);
- myMainLayout->addWidget(aFrm);
+ ModuleBase_Tools::zeroMargins(aBtnLay);
+ myMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
QStringList aBtnNames;
aBtnNames << QString(PROP_PANEL_HELP)
aBtnLay->addWidget(aBtn);
}
aBtnLay->insertStretch(1, 1);
- // aBtn->setShortcut(QKeySequence(Qt::Key_Escape));
myCustomWidget = new QWidget(aContent);
- myMainLayout->addWidget(myCustomWidget);
+ myCustomWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+ myMainLayout->addWidget(myCustomWidget, aPanelRow, kPanelColumn);
setStretchEnabled(true);
}
{
myWidgets = theWidgets;
if (theWidgets.empty()) return;
- bool isEnableStretch = true;
- QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast =
- theWidgets.end();
- for (; anIt != aLast; anIt++) {
+ QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin();
+ for (; anIt != theWidgets.end(); anIt++) {
connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
this, SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
this, SLOT(activateWidget(ModuleBase_ModelWidget*)));
-
- //ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
- //if (aPointWidget)
- // connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
- // SIGNAL(storedPoint2D(ObjectPtr, const std::string&)))
- //}
-
- if (!isEnableStretch) continue;
- foreach(QWidget* eachWidget, (*anIt)->getControls()) {
- QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
- if(aVPolicy == QSizePolicy::Expanding ||
- aVPolicy == QSizePolicy::MinimumExpanding) {
- isEnableStretch = false;
- }
- }
}
- setStretchEnabled(isEnableStretch);
ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
if (aLastWidget) {
QList<QWidget*> aControls = aLastWidget->getControls();
void XGUI_PropertyPanel::setStretchEnabled(bool isEnabled)
{
- if (myMainLayout->count() == 0)
+ int aStretchIdx = myMainLayout->rowCount() - 1;
+ if (aStretchIdx < 0)
return;
- int aStretchIdx = myMainLayout->count() - 1;
- bool hasStretch = myMainLayout->itemAt(aStretchIdx)->spacerItem() != NULL;
- QLayoutItem* aChild;
- if (isEnabled) {
- if (!hasStretch) myMainLayout->addStretch(1);
- } else if (hasStretch) {
- aChild = myMainLayout->takeAt(aStretchIdx);
- delete aChild;
- }
+ myMainLayout->setRowStretch(aStretchIdx, isEnabled ? 1 : 0);
}
void XGUI_PropertyPanel::activateNextWidget()
class XGUI_ActionsMgr;
class QKeyEvent;
-class QVBoxLayout;
+class QGridLayout;
/// Internal name of property panel widget
const static char* PROP_PANEL = "property_panel_dock";
private:
QWidget* myCustomWidget;
QList<ModuleBase_ModelWidget*> myWidgets;
- QVBoxLayout* myMainLayout;
+ QGridLayout* myMainLayout;
/// Currently active widget
ModuleBase_ModelWidget* myActiveWidget;