return result;
}
-bool Config_WidgetAPI::isContainerWidget() const
+bool Config_WidgetAPI::isGroupBoxWidget() const
{
return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP,
- NULL);
+ NULL);
}
bool Config_WidgetAPI::isPagedWidget() const
{
return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH,
- NULL);
+ NULL);
}
std::string Config_WidgetAPI::getProperty(const char* thePropName) const
//! Returns name of widget's node (attribute)
std::string widgetType() const;
//! Returns true if widget has container type, which means it able to contain other widgets
- bool isContainerWidget() const;
+ bool isGroupBoxWidget() const;
//! Returns true if widget has page type;
//! Page is container widget with combo box control to switch between pages
bool isPagedWidget() const;
ModuleBase_Preferences.h
ModuleBase_ActionInfo.h
ModuleBase_WidgetToolbox.h
+ ModuleBase_PageBase.h
+ ModuleBase_PageWidget.h
+ ModuleBase_PageGroupBox.h
)
SET(PROJECT_SOURCES
ModuleBase_Preferences.cpp
ModuleBase_ActionInfo.cpp
ModuleBase_WidgetToolbox.cpp
+ ModuleBase_PageBase.cpp
+ ModuleBase_PageWidget.cpp
+ ModuleBase_PageGroupBox.cpp
)
SET(PROJECT_LIBRARIES
/// \param theWidgetApi the widget configuation. The attribute of the model widget is obtained from\r
/// \param theParentId is Id of a parent of the current attribute\r
/// \param theModelWidgets list of widget objects\r
- virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
- Config_WidgetAPI* theWidgetApi, std::string theParentId,\r
- QList<ModuleBase_ModelWidget*>& theModelWidgets)\r
+ virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
+ Config_WidgetAPI* theWidgetApi, std::string theParentId)\r
{\r
return 0;\r
}\r
--- /dev/null
+/*
+ * ModuleBase_PageBase.cpp
+ *
+ * Created on: Mar 4, 2015
+ * Author: sbh
+ */
+
+#include <ModuleBase_PageBase.h>
+#include <ModuleBase_ModelWidget.h>
+
+#include <QLayout>
+
+class QWidget;
+
+ModuleBase_PageBase::ModuleBase_PageBase()
+{
+
+}
+
+ModuleBase_PageBase::~ModuleBase_PageBase()
+{
+
+}
+
+void ModuleBase_PageBase::addModelWidget(ModuleBase_ModelWidget* theWidget)
+{
+ placeModelWidget(theWidget);
+ myWidgetList.append(theWidget);
+}
+
+void ModuleBase_PageBase::addPageWidget(ModuleBase_PageBase* thePage)
+{
+ placePageWidget(thePage);
+}
+
+void ModuleBase_PageBase::clearPage()
+{
+ qDeleteAll(pageLayout()->children());
+ myWidgetList.clear();
+}
+
+
+void ModuleBase_PageBase::takeFocus()
+{
+ if(myWidgetList.isEmpty())
+ return;
+
+ myWidgetList.first()->focusTo();
+}
+
+QList<ModuleBase_ModelWidget*> ModuleBase_PageBase::modelWidgets()
+{
+ return myWidgetList;
+}
--- /dev/null
+/*
+ * ModuleBase_PageBase.h
+ *
+ * Created on: Mar 4, 2015
+ * Author: sbh
+ */
+
+#ifndef MODULEBASE_PAGEBASE_H_
+#define MODULEBASE_PAGEBASE_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_Tools.h>
+
+class ModuleBase_ModelWidget;
+class QLayout;
+class QWidget;
+
+/*!
+ * Represent a property panel's list of ModuleBase_ModelWidgets.
+ */
+class MODULEBASE_EXPORT ModuleBase_PageBase
+{
+ public:
+ ModuleBase_PageBase();
+ virtual ~ModuleBase_PageBase();
+
+ void addModelWidget(ModuleBase_ModelWidget* theWidget);
+ void addPageWidget(ModuleBase_PageBase* theWidget);
+
+ void clearPage();
+ void takeFocus();
+ QList<ModuleBase_ModelWidget*> modelWidgets();
+
+ protected:
+ virtual void placeModelWidget(ModuleBase_ModelWidget* theWidget) = 0;
+ virtual void placePageWidget(ModuleBase_PageBase* theWidget) = 0;
+ virtual QLayout* pageLayout() = 0;
+
+ private:
+ QList<ModuleBase_ModelWidget*> myWidgetList;
+
+};
+
+#endif /* MODULEBASE_PAGEBASE_H_ */
--- /dev/null
+/*
+ * ModuleBase_PageGroupBox.cpp
+ *
+ * Created on: Mar 4, 2015
+ * Author: sbh
+ */
+
+#include <ModuleBase_PageGroupBox.h>
+#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_Tools.h>
+
+#include <QGridLayout>
+
+ModuleBase_PageGroupBox::ModuleBase_PageGroupBox(QWidget* theParent)
+: QGroupBox(theParent)
+{
+ myMainLayout = new QGridLayout(this);
+ ModuleBase_Tools::adjustMargins(myMainLayout);
+ setLayout(myMainLayout);
+}
+
+ModuleBase_PageGroupBox::~ModuleBase_PageGroupBox()
+{
+}
+
+void ModuleBase_PageGroupBox::placeModelWidget(ModuleBase_ModelWidget* theWidget)
+{
+ const int kCol = 0;
+ const int kRow = myMainLayout->count();
+ myMainLayout->addWidget(theWidget, kRow, kCol, Qt::AlignTop | Qt::AlignLeft);
+}
+
+void ModuleBase_PageGroupBox::placePageWidget(ModuleBase_PageBase* theWidget)
+{
+ QWidget* aWidget = dynamic_cast<QWidget*>(theWidget);
+ if (!aWidget) {
+ #ifdef _DEBUG
+ std::cout << "ModuleBase_PageGroupBox::placePageWidget: can not cast page" << std::endl;
+ #endif
+ return;
+ }
+ const int kCol = 0;
+ const int kRow = myMainLayout->count();
+ myMainLayout->addWidget(aWidget, kRow, kCol, Qt::AlignTop | Qt::AlignLeft);
+}
+
+QLayout* ModuleBase_PageGroupBox::pageLayout()
+{
+ return myMainLayout;
+}
--- /dev/null
+/*
+ * ModuleBase_PageGroupBox.h
+ *
+ * Created on: Mar 4, 2015
+ * Author: sbh
+ */
+
+#ifndef MODULEBASE_PAGEGROUPBOX_H_
+#define MODULEBASE_PAGEGROUPBOX_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_PageBase.h>
+
+#include <QGroupBox>
+#include <QList>
+
+class ModuleBase_ModelWidget;
+class QGridLayout;
+
+
+/*!
+ * Represent a property panel's list of ModuleBase_ModelWidgets.
+ */
+class MODULEBASE_EXPORT ModuleBase_PageGroupBox : public QGroupBox, public ModuleBase_PageBase
+{
+ public:
+ explicit ModuleBase_PageGroupBox(QWidget* theParent = 0);
+ virtual ~ModuleBase_PageGroupBox();
+
+ protected:
+ virtual void placeModelWidget(ModuleBase_ModelWidget* theWidget);
+ virtual void placePageWidget(ModuleBase_PageBase* theWidget);
+ virtual QLayout* pageLayout();
+
+ private:
+ QGridLayout* myMainLayout;
+};
+
+#endif /* MODULEBASE_PAGEGROUPBOX_H_ */
--- /dev/null
+/*
+ * ModuleBase_PageWidget.cpp
+ *
+ * Created on: Mar 4, 2015
+ * Author: sbh
+ */
+
+#include <ModuleBase_PageWidget.h>
+#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_Tools.h>
+
+#include <QGridLayout>
+
+ModuleBase_PageWidget::ModuleBase_PageWidget(QWidget* theParent)
+: QFrame(theParent)
+{
+ myMainLayout = new QGridLayout(this);
+ ModuleBase_Tools::adjustMargins(myMainLayout);
+ setLayout(myMainLayout);
+}
+
+ModuleBase_PageWidget::~ModuleBase_PageWidget()
+{
+}
+
+void ModuleBase_PageWidget::placeModelWidget(ModuleBase_ModelWidget* theWidget)
+{
+ const int kCol = 0;
+ const int kRow = myMainLayout->count();
+ myMainLayout->addWidget(theWidget, kRow, kCol, Qt::AlignTop | Qt::AlignLeft);
+}
+
+void ModuleBase_PageWidget::placePageWidget(ModuleBase_PageBase* theWidget)
+{
+ QWidget* aWidget = dynamic_cast<QWidget*>(theWidget);
+ if (!aWidget) {
+ #ifdef _DEBUG
+ std::cout << "ModuleBase_PageWidget::placePageWidget: can not cast page" << std::endl;
+ #endif
+ return;
+ }
+ const int kCol = 0;
+ const int kRow = myMainLayout->count();
+ myMainLayout->addWidget(aWidget, kRow, kCol, Qt::AlignTop | Qt::AlignLeft);
+}
+
+QLayout* ModuleBase_PageWidget::pageLayout()
+{
+ return myMainLayout;
+}
--- /dev/null
+/*
+ * ModuleBase_PageWidget.h
+ *
+ * Created on: Mar 4, 2015
+ * Author: sbh
+ */
+
+#ifndef MODULEBASE_PAGEWIDGET_H_
+#define MODULEBASE_PAGEWIDGET_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_PageBase.h>
+
+#include <QFrame>
+#include <QList>
+
+class ModuleBase_ModelWidget;
+class QGridLayout;
+
+/*!
+ * Represent a property panel's list of ModuleBase_ModelWidgets.
+ */
+class MODULEBASE_EXPORT ModuleBase_PageWidget : public QFrame, public ModuleBase_PageBase
+{
+ public:
+ explicit ModuleBase_PageWidget(QWidget* theParent = 0);
+ virtual ~ModuleBase_PageWidget();
+
+ protected:
+ virtual void placeModelWidget(ModuleBase_ModelWidget* theWidget);
+ virtual void placePageWidget(ModuleBase_PageBase* theWidget);
+ virtual QLayout* pageLayout();
+
+ private:
+ QGridLayout* myMainLayout;
+};
+
+#endif /* MODULEBASE_PAGEWIDGET_H_ */
#include <ModuleBase_WidgetMultiSelector.h>
#include <ModuleBase_WidgetLabel.h>
#include <ModuleBase_WidgetToolbox.h>
+#include <ModuleBase_PageBase.h>
+#include <ModuleBase_PageGroupBox.h>
+#include <ModuleBase_PageWidget.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Session.h>
delete myWidgetApi;
}
-void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
+void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage)
{
myParentId = myWidgetApi->widgetId();
if (!myWidgetApi->toChildWidget())
return;
- QVBoxLayout* aWidgetLay = new QVBoxLayout(theParent);
- bool isStretchLayout = false;
+ //bool isStretchLayout = false;
+ QWidget* aPageWidget = dynamic_cast<QWidget*>(thePage);
+ if(!aPageWidget) {
+ #ifdef _DEBUG
+ std::cout << "ModuleBase_WidgetFactory::createWidget: can not reinterpret_cast thePage" << std::endl;
+ #endif
+ }
do { //Iterate over each node
std::string aWdgType = myWidgetApi->widgetType();
- //Create a widget (doublevalue, groupbox, toolbox, etc.
- QWidget* aWidget = createWidgetByType(aWdgType, theParent);
- if (aWidget) {
- if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) {
- aWidgetLay->addWidget(aWidget);
- } else {
- aWidget->setVisible(false);
- }
- }
- if (myWidgetApi->isContainerWidget()) {
+ // Create PageGroup TODO: extract
+ if (myWidgetApi->isGroupBoxWidget()) {
//if current widget is groupbox (container) process it's children recursively
QString aGroupName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
- createWidget(aWidget);
- ModuleBase_Tools::adjustMargins(aWidget);
- QGroupBox* aGrBox = qobject_cast<QGroupBox*>(aWidget);
- aGrBox->setTitle(aGroupName);
- }
- if (myWidgetApi->isPagedWidget()) {
- //If current widget is toolbox or switch-casebox then fetch all
- //it's pages recursively and setup into the widget.
- myWidgetApi->toChildWidget();
- do {
- QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
- QString aCaseId = qs(myWidgetApi->getProperty(_ID));
- QWidget* aPage = new QWidget(aWidget);
- createWidget(aPage);
- ModuleBase_Tools::adjustMargins(aPage);
- if (aWdgType == WDG_SWITCH) {
- ModuleBase_WidgetSwitch* aSwitch = qobject_cast<ModuleBase_WidgetSwitch*>(aWidget);
- aSwitch->addPage(aPage, aPageName);
- } else if (aWdgType == WDG_TOOLBOX) {
- ModuleBase_WidgetToolbox* aToolbox = qobject_cast<ModuleBase_WidgetToolbox*>(aWidget);
- aToolbox->addPage(aPage, aPageName, aCaseId);
+ ModuleBase_PageGroupBox* aPage = new ModuleBase_PageGroupBox(aPageWidget);
+ aPage->setTitle(aGroupName);
+ createWidget(aPage);
+ thePage->addPageWidget(aPage);
+ } else {
+ // Create a ModelWidget
+ ModuleBase_ModelWidget* aWidget = createWidgetByType(aWdgType, aPageWidget);
+ if (aWidget) {
+ if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) {
+ thePage->addModelWidget(aWidget);
+ } else {
+ aWidget->setVisible(false);
}
- } while (myWidgetApi->toNextWidget());
- }
- if (aWidget && !isStretchLayout) {
- isStretchLayout = !hasExpandingControls(aWidget);
+ }
+ // Create PagedContainer TODO: extract
+ if (myWidgetApi->isPagedWidget()) {
+ //If current widget is toolbox or switch-casebox then fetch all
+ //it's pages recursively and setup into the widget.
+ myWidgetApi->toChildWidget();
+ do {
+ QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
+ QString aCaseId = qs(myWidgetApi->getProperty(_ID));
+ ModuleBase_PageBase* aPage = new ModuleBase_PageWidget(aWidget);
+ createWidget(aPage);
+ QWidget* aCasePageWidget = dynamic_cast<QWidget*>(aPage);
+ if (aWdgType == WDG_SWITCH) {
+ ModuleBase_WidgetSwitch* aSwitch = qobject_cast<ModuleBase_WidgetSwitch*>(aWidget);
+ aSwitch->addPage(aCasePageWidget, aPageName);
+ } else if (aWdgType == WDG_TOOLBOX) {
+ ModuleBase_WidgetToolbox* aToolbox = qobject_cast<ModuleBase_WidgetToolbox*>(aWidget);
+ aToolbox->addPage(aCasePageWidget, aPageName, aCaseId);
+ }
+ } while (myWidgetApi->toNextWidget());
+ }
}
+// if (aWidget && !isStretchLayout) {
+// isStretchLayout = !hasExpandingControls(aWidget);
+// }
} while (myWidgetApi->toNextWidget());
- if (isStretchLayout) {
- aWidgetLay->addStretch(1);
- }
- theParent->setLayout(aWidgetLay);
+// if (isStretchLayout) {
+// aWidgetLay->addStretch(1);
+// }
}
bool ModuleBase_WidgetFactory::hasExpandingControls(QWidget* theParent)
return result;
}
-QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType,
- QWidget* theParent)
+ModuleBase_ModelWidget* ModuleBase_WidgetFactory
+::createWidgetByType(const std::string& theType, QWidget* theParent)
{
- QWidget* result = NULL;
- if (theType == WDG_DOUBLEVALUE) {
- result = doubleSpinBoxControl(theParent);
+ ModuleBase_ModelWidget* result = NULL;
+
+ if (theType == WDG_INFO) {
+ result = new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId);
- } else if (theType == WDG_INFO) {
- result = labelControl(theParent);
+ } else if (theType == WDG_DOUBLEVALUE) {
+ result = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId);
} else if (theType == WDG_SHAPE_SELECTOR) {
- result = shapeSelectorControl(theParent);
+ result = new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi, myParentId);
} else if (theType == WDG_BOOLVALUE) {
- result = booleanControl(theParent);
+ result = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId);
} else if (theType == WDG_DOUBLEVALUE_EDITOR) {
- result = doubleValueEditor(theParent);
+ result = new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId);
} else if (theType == WDG_FILE_SELECTOR) {
- result = fileSelectorControl(theParent);
+ result = new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId);
} else if (theType == WDG_CHOICE) {
- result = choiceControl(theParent);
+ result = new ModuleBase_WidgetChoice(theParent, myWidgetApi,myParentId);
} else if (theType == WDG_STRINGVALUE) {
- result = lineEditControl(theParent);
+ result = new ModuleBase_WidgetLineEdit(theParent, myWidgetApi,myParentId);
} else if (theType == WDG_MULTISELECTOR) {
- result = multiSelectorControl(theParent);
+ result = new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi,myParentId);
+
+ } else if (theType == WDG_TOOLBOX) {
+ result = new ModuleBase_WidgetToolbox(theParent, myWidgetApi, myParentId);
- } else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
- result = createContainer(theType, theParent);
+ } else if (theType == WDG_SWITCH) {
+ result = new ModuleBase_WidgetSwitch(theParent, myWidgetApi, myParentId);
+ return result;
+
+ } else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) {
+ // Do nothing for "box" and "case"
+ result = NULL;
} else {
result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi,
- myParentId, myModelWidgets);
+ myParentId);
#ifdef _DEBUG
if (!result) {qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type");}
#endif
}
- return result;
-}
-
-QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, QWidget* theParent)
-{
- QWidget* aResult = NULL;
- if (theType == WDG_GROUP || theType == WDG_CHECK_GROUP) {
- QGroupBox* aGroupBox = new QGroupBox(theParent);
- aGroupBox->setCheckable(theType == WDG_CHECK_GROUP);
- aResult = aGroupBox;
- } else if (theType == WDG_TOOLBOX) {
- ModuleBase_WidgetToolbox* aWdg = new ModuleBase_WidgetToolbox(theParent, myWidgetApi, myParentId);
- myModelWidgets.append(aWdg);
- aResult = aWdg;
- } else if (theType == WDG_SWITCH) {
- aResult = new ModuleBase_WidgetSwitch(theParent);
- } else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) {
- // Do nothing for "box" and "case"
- aResult = NULL;
+ if (result) {
+ myModelWidgets.append(result);
}
-#ifdef _DEBUG
- else {qDebug() << "ModuleBase_WidgetFactory::fillWidget: find bad container type";}
-#endif
- return aResult;
-}
-
-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;
-}
-
-QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent)
-{
- ModuleBase_WidgetEditor* aWidget =
- new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId);
- myModelWidgets.append(aWidget);
- return aWidget;
-}
-
-QWidget* ModuleBase_WidgetFactory::shapeSelectorControl(QWidget* theParent)
-{
- ModuleBase_WidgetShapeSelector* aSelector =
- new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi, myParentId);
- myModelWidgets.append(aSelector);
- return aSelector;
-}
-
-QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
-{
- ModuleBase_WidgetBoolValue* aBoolWgt =
- new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId);
- myModelWidgets.append(aBoolWgt);
- return aBoolWgt;
-}
-
-QWidget* ModuleBase_WidgetFactory::fileSelectorControl(QWidget* theParent)
-{
- ModuleBase_WidgetFileSelector* aFileSelectorWgt =
- new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId);
- myModelWidgets.append(aFileSelectorWgt);
- return aFileSelectorWgt;
-}
-
-QWidget* ModuleBase_WidgetFactory::choiceControl(QWidget* theParent)
-{
- ModuleBase_WidgetChoice* aChoiceWgt =
- new ModuleBase_WidgetChoice(theParent, myWidgetApi,myParentId);
- myModelWidgets.append(aChoiceWgt);
- return aChoiceWgt;
-}
-
-QWidget* ModuleBase_WidgetFactory::lineEditControl(QWidget* theParent)
-{
- ModuleBase_WidgetLineEdit* aLineEditWgt =
- new ModuleBase_WidgetLineEdit(theParent, myWidgetApi,myParentId);
- myModelWidgets.append(aLineEditWgt);
- return aLineEditWgt;
-}
-
-QWidget* ModuleBase_WidgetFactory::multiSelectorControl(QWidget* theParent)
-{
- ModuleBase_WidgetMultiSelector* aMultiselectorWgt =
- new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi,myParentId);
- myModelWidgets.append(aMultiselectorWgt);
- return aMultiselectorWgt;
+ return result;
}
QString ModuleBase_WidgetFactory::qs(const std::string& theStdString)
* Author: sbh
*/
-#ifndef ModuleBase_WidgetFactory_H_
-#define ModuleBase_WidgetFactory_H_
+#ifndef MODULEBASE_WIDGETFACTORY_H_
+#define MODULEBASE_WIDGETFACTORY_H_
-#include "ModuleBase.h"
-#include "ModuleBase_ModelWidget.h"
+#include <ModuleBase.h>
+#include <ModuleBase_ModelWidget.h>
#include <QString>
#include <QList>
class QWidget;
class Config_WidgetAPI;
class ModuleBase_IWorkshop;
+class ModuleBase_PageBase;
/**
* \ingroup GUI
/// Creates content widget for property panel
/// \param theParent a parent widget
- void createWidget(QWidget* theParent);
+ void createWidget(ModuleBase_PageBase* theParent);
/// Returns list of model widgets
/// Create widget by its type
/// \param theType a type
/// \param theParent a parent widget
- QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL);
-
- /// Create a widget of container type
- /// \param theType a type
- /// \param theParent a parent widget
- QWidget* createContainer(const std::string& theType, QWidget* theParent);
-
- /// Create label widget
- /// \param theParent a parent widget
- QWidget* labelControl(QWidget* theParent);
-
- /// Create double spin box widget
- /// \param theParent a parent widget
- QWidget* doubleSpinBoxControl(QWidget* theParent);
-
- /// Create double value editor widget
- /// \param theParent a parent widget
- QWidget* doubleValueEditor(QWidget* theParent);
-
- /// Create shape selector widget
- /// \param theParent a parent widget
- QWidget* shapeSelectorControl(QWidget* theParent);
-
- /// Create boolean input widget
- /// \param theParent a parent widget
- QWidget* booleanControl(QWidget* theParent);
-
- /// Create file selector widget
- /// \param theParent a parent widget
- QWidget* fileSelectorControl(QWidget* theParent);
-
- /// Create choice widget (combo box)
- /// \param theParent a parent widget
- QWidget* choiceControl(QWidget* theParent);
-
- /// Create line edit widget
- /// \param theParent a parent widget
- QWidget* lineEditControl(QWidget* theParent);
-
- /// Create multi selector widget
- /// \param theParent a parent widget
- QWidget* multiSelectorControl(QWidget* theParent);
+ ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
+ QWidget* theParent = NULL);
/// Convert STD string to QT string
/// \param theStdString is STD string
*/
#include <ModuleBase_WidgetSwitch.h>
+#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_PageBase.h>
#include <QComboBox>
#include <QVBoxLayout>
#include <QSpacerItem>
-ModuleBase_WidgetSwitch::ModuleBase_WidgetSwitch(QWidget* parent)
- : QFrame(parent)
+
+ModuleBase_WidgetSwitch::ModuleBase_WidgetSwitch(QWidget* theParent, const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
myMainLay = new QVBoxLayout(this);
myMainLay->setContentsMargins(2, 4, 2, 2);
myCombo = new QComboBox(this);
myCombo->hide();
myMainLay->addWidget(myCombo);
- this->setFrameShape(QFrame::StyledPanel);
+ //this->setFrameShape(QFrame::StyledPanel);
connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentIndex(int)));
connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(currentPageChanged(int)));
{
}
+QList<QWidget*> ModuleBase_WidgetSwitch::getControls() const
+{
+ QList<QWidget*> aList;
+ aList << myCombo;
+ return aList;
+}
+
int ModuleBase_WidgetSwitch::addPage(QWidget* theWidget, const QString& theName)
{
return insertPage(count(), theWidget, theName);
#define ModuleBase_WidgetSwitch_H_
#include <ModuleBase.h>
-#include <QFrame>
+#include <ModuleBase_ModelWidget.h>
class QComboBox;
class QVBoxLayout;
* \ingroup GUI
* Implements a model widget for swithch as a container widget. It can be defined in XML with "switch" keyword
*/
-class MODULEBASE_EXPORT ModuleBase_WidgetSwitch : public QFrame
+class MODULEBASE_EXPORT ModuleBase_WidgetSwitch : public ModuleBase_ModelWidget
{
-Q_OBJECT
+ Q_OBJECT
public:
/// Constructor
/// \param parent a parent widget
- ModuleBase_WidgetSwitch(QWidget* parent = NULL);
+ ModuleBase_WidgetSwitch(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId);
virtual ~ModuleBase_WidgetSwitch();
+ virtual bool restoreValue() {
+ return false;
+ }
+
+ virtual QList<QWidget*> getControls() const;
+
+ virtual bool focusTo() {
+ return false;
+ }
+
/// Add a page to the widget
/// \param theWidget a page widget
/// \param theName a name of page
- int addPage(QWidget * theWidget, const QString & theName);
+ int addPage(QWidget* theWidget, const QString & theName);
/// Returns count of pages
int count() const;
void currentPageChanged(int);
protected:
+ virtual bool storeValueCustom() const {
+ return false;
+ }
/// Update widget
void refresh();
*/
#include <ModuleBase_WidgetToolbox.h>
+#include <ModuleBase_PageBase.h>
#include <ModuleBase_Tools.h>
#include <ModelAPI_AttributeString.h>
return aList;
}
+bool ModuleBase_WidgetToolbox::focusTo()
+{
+ return false;
+}
+
bool ModuleBase_WidgetToolbox::storeValueCustom() const
{
// A rare case when plugin was not loaded.
#include <QToolBox>
+class ModuleBase_PageBase;
+
class ModuleBase_WidgetToolbox : public ModuleBase_ModelWidget
{
Q_OBJECT
virtual bool restoreValue();
virtual QList<QWidget*> getControls() const;
+ virtual bool focusTo();
int addPage(QWidget* theWidget, const QString& theName, const QString& theCaseId);
}
}
-QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
- Config_WidgetAPI* theWidgetApi, std::string theParentId,
- QList<ModuleBase_ModelWidget*>& theModelWidgets)
+ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
+ Config_WidgetAPI* theWidgetApi, std::string theParentId)
{
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
XGUI_Workshop* aWorkshop = aConnector->workshop();
aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
aWgt = aConstraintShapeSelectorWgt;
}
- if(aWgt)
- theModelWidgets.append(aWgt);
return aWgt;
}
virtual ~PartSet_Module();
/// Creates custom widgets for property panel
- virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
- Config_WidgetAPI* theWidgetApi, std::string theParentId,
- QList<ModuleBase_ModelWidget*>& theModelWidgets);
+ virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
+ Config_WidgetAPI* theWidgetApi, std::string theParentId);
/// Call back forlast tuning of property panel before operation performance
virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
//#include <AppElements_Constants.h>
#include <ModuleBase_WidgetMultiSelector.h>
#include <ModuleBase_Tools.h>
+#include <ModuleBase_PageBase.h>
+#include <ModuleBase_PageWidget.h>
#include <QEvent>
#include <QFrame>
XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
: ModuleBase_IPropertyPanel(theParent),
- myActiveWidget(NULL)
+ myActiveWidget(NULL),
+ myPanelPage(NULL)
{
this->setWindowTitle(tr("Property Panel"));
QAction* aViewAct = this->toggleViewAction();
setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
QWidget* aContent = new QWidget(this);
- myMainLayout = new QGridLayout(aContent);
+ QGridLayout* aMainLayout = new QGridLayout(aContent);
const int kPanelColumn = 0;
int aPanelRow = 0;
- myMainLayout->setContentsMargins(3, 3, 3, 3);
+ aMainLayout->setContentsMargins(3, 3, 3, 3);
this->setWidget(aContent);
QFrame* aFrm = new QFrame(aContent);
aFrm->setFrameShape(QFrame::Panel);
QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
ModuleBase_Tools::zeroMargins(aBtnLay);
- myMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
+ aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
QStringList aBtnNames;
aBtnNames << QString(PROP_PANEL_HELP)
}
aBtnLay->insertStretch(1, 1);
- myCustomWidget = new QWidget(aContent);
- myCustomWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
- myMainLayout->addWidget(myCustomWidget, aPanelRow, kPanelColumn);
- setStretchEnabled(true);
+ myPanelPage = new ModuleBase_PageWidget(aContent);
+ myPanelPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+ aMainLayout->addWidget(myPanelPage, aPanelRow, kPanelColumn);
}
XGUI_PropertyPanel::~XGUI_PropertyPanel()
if (myActiveWidget)
myActiveWidget->deactivate();
myWidgets.clear();
- qDeleteAll(myCustomWidget->children());
+ myPanelPage->clearPage();
myActiveWidget = NULL;
setWindowTitle(tr("Property Panel"));
}
return myWidgets;
}
-QWidget* XGUI_PropertyPanel::contentWidget()
+ModuleBase_PageBase* XGUI_PropertyPanel::contentWidget()
{
- return myCustomWidget;
+
+ return static_cast<ModuleBase_PageBase*>(myPanelPage);
}
void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
//}
}
-void XGUI_PropertyPanel::setStretchEnabled(bool isEnabled)
-{
- int aStretchIdx = myMainLayout->rowCount() - 1;
- if (aStretchIdx < 0)
- return;
- myMainLayout->setRowStretch(aStretchIdx, isEnabled ? 1 : 0);
-}
-
void XGUI_PropertyPanel::activateNextWidget()
{
activateNextWidget(myActiveWidget);
class XGUI_ActionsMgr;
class QKeyEvent;
class QGridLayout;
+class ModuleBase_PageBase;
+class ModuleBase_PageWidget;
/// Internal name of property panel widget
const static char* PROP_PANEL = "property_panel_dock";
/// Returns main widget of the property panel, which children will be created
/// by WidgetFactory using the XML definition
- QWidget* contentWidget();
+ ModuleBase_PageBase* contentWidget();
/// Brings back all widget created by widget factory for signal/slot
/// connections and further processing
/// Activate the next from current widget in the property panel
virtual void activateNextWidget();
- /// \brief Enable/Disable stretch area in the panel
- void setStretchEnabled(bool isEnabled);
-
/// Set Enable/Disable state of Cancel button
/// \param theEnabled Enable/Disable state of Cancel button
virtual void setCancelEnabled(bool theEnabled);
virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
private:
- QWidget* myCustomWidget;
+ ModuleBase_PageWidget* myPanelPage;
QList<ModuleBase_ModelWidget*> myWidgets;
- QGridLayout* myMainLayout;
/// Currently active widget
ModuleBase_ModelWidget* myActiveWidget;
myPropertyPanel->cleanContent();
aFactory.createWidget(myPropertyPanel->contentWidget());
- ModuleBase_Tools::zeroMargins(myPropertyPanel->contentWidget());
QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {