ModuleBase_WidgetValidator.h
ModuleBase_IconFactory.h
ModuleBase_Dialog.h
+ ModuleBase_ModelDialogWidget.h
)
SET(PROJECT_SOURCES
#include "ModuleBase_IWorkshop.h"
#include "ModuleBase_IPropertyPanel.h"
#include "ModuleBase_PageWidget.h"
+#include "ModuleBase_ModelDialogWidget.h"
#include <ModelAPI_Session.h>
#include <ModelAPI_Events.h>
aFactory.createWidget(aPage, false);
myWidgets = aFactory.getModelWidgets();
- foreach (ModuleBase_ModelWidget* aWidget, myWidgets) {
- initializeWidget(aWidget);
- }
QFrame* aFrame = new QFrame(this);
aFrame->setFrameStyle(QFrame::WinPanel | QFrame::Raised);
QVBoxLayout* aBtnLayout = new QVBoxLayout(aFrame);
ModuleBase_Tools::adjustMargins(aBtnLayout);
- QDialogButtonBox* aBtnBox = new QDialogButtonBox(
+ myButtonsBox = new QDialogButtonBox(
QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, aFrame);
- aBtnLayout->addWidget(aBtnBox);
+ aBtnLayout->addWidget(myButtonsBox);
+
+ myButtonsBox->button(QDialogButtonBox::Ok)->setIcon(QIcon(":pictures/button_ok.png"));
+ myButtonsBox->button(QDialogButtonBox::Cancel)->setIcon(QIcon(":pictures/button_cancel.png"));
- aBtnBox->button(QDialogButtonBox::Ok)->setIcon(QIcon(":pictures/button_ok.png"));
- aBtnBox->button(QDialogButtonBox::Cancel)->setIcon(QIcon(":pictures/button_cancel.png"));
+ connect(myButtonsBox, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(myButtonsBox, SIGNAL(rejected()), this, SLOT(reject()));
- connect(aBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
- connect(aBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
+ foreach (ModuleBase_ModelWidget* aWidget, myWidgets) {
+ initializeWidget(aWidget);
+ }
}
void ModuleBase_Dialog::initializeWidget(ModuleBase_ModelWidget* theWidget)
{
+ ModuleBase_ModelDialogWidget* aDlgWgt = dynamic_cast<ModuleBase_ModelDialogWidget*>(theWidget);
+ if (aDlgWgt)
+ aDlgWgt->setDialogButtons(myButtonsBox);
+
theWidget->setFeature(myFeature);
theWidget->restoreValue();
}
class ModuleBase_IWorkshop;
class ModuleBase_ModelWidget;
+class QDialogButtonBox;
+
/**
* \ingroup GUI
/// Redefinition of virtual method
virtual void showEvent(QShowEvent* theEvent);
-
private:
/// Initialising of the widget
void initializeWidget(ModuleBase_ModelWidget* theWidget);
/// Pointer on active widget
ModuleBase_ModelWidget* myActiveWidget;
+
+ /// Buttons of the dialog
+ QDialogButtonBox* myButtonsBox;
};
#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_ModelDialogWidget.h
+// Created: 01 June 2016
+// Author: Vitaly SMETANNIKOV
+
+#ifndef MODULEBASE_MODELDIALOGWIDGET_H
+#define MODULEBASE_MODELDIALOGWIDGET_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_ModelWidget.h"
+
+class QDialogButtonBox;
+
+class MODULEBASE_EXPORT ModuleBase_ModelDialogWidget : public ModuleBase_ModelWidget
+{
+Q_OBJECT
+public:
+ /// Constructor
+ /// \param theParent the parent object
+ /// \param theData the widget configuration. The attribute of the model widget is obtained from
+ /// a low-level API for reading xml definitions of widgets
+ ModuleBase_ModelDialogWidget(QWidget* theParent, const Config_WidgetAPI* theData) :
+ ModuleBase_ModelWidget(theParent, theData) {}
+
+ /// Set general buttons from dialog
+ /// \param theButtons the dialog buttons
+ void setDialogButtons(QDialogButtonBox* theButtons) { myOkCancelBtn = theButtons; }
+
+protected:
+
+ /// Contains dialog buttons to enable/disable Ok and Cancel buttons
+ QDialogButtonBox* myOkCancelBtn;
+};
+
+#endif
\ No newline at end of file
#include <QTimer>
#include <QEvent>
#include <QKeyEvent>
+#include <QDialogButtonBox>
enum ColumnType {
Col_Name,
/////////////////////////////////////////////////////////////////////////////////////////////////
ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theParent, const Config_WidgetAPI* theData)
- : ModuleBase_ModelWidget(theParent, theData)
+ : ModuleBase_ModelDialogWidget(theParent, theData)
{
QVBoxLayout* aLayout = new QVBoxLayout(this);
void ParametersPlugin_WidgetParamsMgr::updateParametersPart()
{
updateItem(myParameters, parametersItems(myParametersList));
- bool aIsValid = checkIsValid();
+ bool aIsValid = isValid();
enableButtons(aIsValid);
}
void ParametersPlugin_WidgetParamsMgr::sendWarning()
{
QMessageBox::warning(this, tr("Warning"), myMessage);
+ QTreeWidgetItem* aItem = myTable->currentItem();
+ if (aItem)
+ myTable->editItem(aItem);
}
void ParametersPlugin_WidgetParamsMgr::onSelectionChanged()
{
QList<QTreeWidgetItem*> aItemsList = myTable->selectedItems();
- bool isValid = checkIsValid();
- if (isValid) {
+ bool aIsValid = isValid();
+ if (aIsValid) {
bool isParameter = false;
foreach(QTreeWidgetItem* aItem, aItemsList) {
if (aItem->parent() == myParameters) {
myUpBtn->setEnabled(theEnable);
myDownBtn->setEnabled(theEnable);
}
+ myOkCancelBtn->button(QDialogButtonBox::Ok)->setEnabled(theEnable);
}
-bool ParametersPlugin_WidgetParamsMgr::checkIsValid()
+bool ParametersPlugin_WidgetParamsMgr::isValid()
{
QTreeWidgetItem* aItem;
bool aIsValid = true;
#ifndef ParametersPlugin_WidgetParamsMgr_H_
#define ParametersPlugin_WidgetParamsMgr_H_
-#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_ModelDialogWidget.h>
#include <QModelIndex>
#include <QAbstractItemDelegate>
#include <QTreeWidget>
* \ingroup GUI
* Represent a content of the property panel to show/modify parameters of some feature.
*/
-class ParametersPlugin_WidgetParamsMgr : public ModuleBase_ModelWidget
+class ParametersPlugin_WidgetParamsMgr : public ModuleBase_ModelDialogWidget
{
Q_OBJECT
public:
void updateParametersPart();
+ /// Returns true if values in the widget are valid
+ bool isValid();
+
/// Returns true if parameter with the given name already exists
bool hasName(const QString& theName) const;
/// Enable or disable buttons for parameters managemnt
void enableButtons(bool theEnable);
- bool checkIsValid();
-
QList<QStringList> featuresItems(const QList<FeaturePtr>& theFeatures, QList<FeaturePtr>& theFeatureList) const;
QList<QStringList> parametersItems(const QList<FeaturePtr>& theFeatures) const;