Salome HOME
Issue #2657: Impossible to create sketch line with start point in the origin
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_WidgetParamsMgr.h
index f722402afefa349b91dcb6813a34cc6a0be26bce..0e55044b32dfbfc5d6ea1957240dbd689943a06b 100644 (file)
@@ -1,27 +1,63 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File:        ParametersPlugin_WidgetParamsMgr.h
-// Created:     11 Apr 2016
-// Author:      Vitaly SMETANNIKOV
+// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #ifndef ParametersPlugin_WidgetParamsMgr_H_
 #define ParametersPlugin_WidgetParamsMgr_H_
 
-#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_ModelDialogWidget.h>
 #include <QModelIndex>
 #include <QAbstractItemDelegate>
+#include <QTreeWidget>
 
-class QTreeWidget;
 class QTreeWidgetItem;
 class ParametersPlugin_ItemDelegate;
 class QPushButton;
 class QToolButton;
 
+
+/*!
+ * \ingroup GUI
+ * Redefinition of QTreeWidget for processing of closeEditor event
+ */
+class ParametersPlugin_TreeWidget: public QTreeWidget
+{
+ Q_OBJECT
+public:
+  /// Constructor
+  /// \param theParent a parent widget
+  ParametersPlugin_TreeWidget(QWidget* theParent = 0) : QTreeWidget(theParent) {}
+
+protected slots:
+  /// Redefinition of virtual method
+  /// \param theEditor a editor widget
+  /// \param theHint end of editing hint
+  virtual void closeEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint);
+};
+
+
+
 /*!
  * \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:
@@ -82,7 +118,7 @@ private:
   FeaturePtr createParameter() const;
 
   /// Creates a new item
-  QTreeWidgetItem* createNewItem() const;
+  QTreeWidgetItem* createNewItem(QTreeWidgetItem* theParent) const;
 
   /// Returns currently selected item
   QTreeWidgetItem* selectedItem() const;
@@ -97,17 +133,25 @@ private:
 
   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;
 
-  QList<QStringList> featuresItems(const QList<FeaturePtr>& theFeatures) const;
+  /// Enable or disable buttons for parameters managemnt
+  void enableButtons(bool theEnable);
+
+  QList<QStringList> featuresItems(const QList<FeaturePtr>& theFeatures,
+                                   QList<FeaturePtr>& theFeatureList) const;
   QList<QStringList> parametersItems(const QList<FeaturePtr>& theFeatures) const;
 
-  QTreeWidget* myTable;
+  void updateParametersFeatures();
+
+  ParametersPlugin_TreeWidget* myTable;
   QTreeWidgetItem* myFeatures;
   QTreeWidgetItem* myParameters;
   ParametersPlugin_ItemDelegate* myDelegate;
-  QModelIndex myEditingIndex;
 
   QList<FeaturePtr> myParametersList;