From 64311cfc3456860932db6440a187487c2c9bd6f0 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 19 Aug 2019 16:24:23 +0300 Subject: [PATCH] Initial implementation --- src/Config/Config_Keywords.h | 1 + src/ModuleBase/CMakeLists.txt | 3 + src/ModuleBase/ModuleBase_WidgetFactory.cpp | 3 + .../ModuleBase_WidgetTreeDataSelect.cpp | 57 +++++++++++++++++ .../ModuleBase_WidgetTreeDataSelect.h | 63 +++++++++++++++++++ 5 files changed, 127 insertions(+) create mode 100644 src/ModuleBase/ModuleBase_WidgetTreeDataSelect.cpp create mode 100644 src/ModuleBase/ModuleBase_WidgetTreeDataSelect.h diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index 0a8f4aba4..0f2c7370b 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -53,6 +53,7 @@ const static char* WDG_PLACE_HOLDER = "placeholder"; const static char* WDG_ACTION = "action"; const static char* WDG_POINT_INPUT = "point_input"; const static char* WDG_SELECTION_FILTERS = "selection_filters"; +const static char* WDG_TREE_DATA_SELECTOR = "tree_data_selector"; // Containers const static char* WDG_GROUP = "groupbox"; diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index f8a1ff2c4..9f681554c 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -105,6 +105,7 @@ SET(PROJECT_HEADERS ModuleBase_ITreeNode.h ModuleBase_WidgetSelectionFilter.h ModuleBase_IStepPrs.h + ModuleBase_WidgetTreeDataSelect.h ) SET(PROJECT_MOC_HEADERS @@ -155,6 +156,7 @@ SET(PROJECT_MOC_HEADERS ModuleBase_WidgetRadiobox.h ModuleBase_WidgetPointInput.h ModuleBase_WidgetSelectionFilter.h + ModuleBase_WidgetTreeDataSelect.h ) SET(PROJECT_SOURCES @@ -225,6 +227,7 @@ SET(PROJECT_SOURCES ModuleBase_WidgetPointInput.cpp ModuleBase_WidgetSelectionFilter.cpp ModuleBase_IStepPrs.cpp + ModuleBase_WidgetTreeDataSelect.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 23728c569..5e9fd7e65 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -347,6 +348,8 @@ ModuleBase_ModelWidget* ModuleBase_WidgetFactory::createWidgetByType(const std:: result = new ModuleBase_WidgetPointInput(theParent, myWorkshop, myWidgetApi); } else if (theType == WDG_SELECTION_FILTERS) { result = new ModuleBase_WidgetSelectionFilter(theParent, myWorkshop, myWidgetApi); + } else if (theType == WDG_TREE_DATA_SELECTOR) { + result = new ModuleBase_WidgetTreeDataSelect(theParent, myWorkshop, myWidgetApi); } else { result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi); if (!result) diff --git a/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.cpp b/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.cpp new file mode 100644 index 000000000..7539f1aa6 --- /dev/null +++ b/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.cpp @@ -0,0 +1,57 @@ +// Copyright (C) 2014-2019 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 +// + + +#include + +#include +#include + +ModuleBase_WidgetTreeDataSelect::ModuleBase_WidgetTreeDataSelect(QWidget* theParent, + ModuleBase_IWorkshop* theWorkshop, + const Config_WidgetAPI* theData) + :ModuleBase_ModelWidget(theParent, theData), myWorkshop(theWorkshop) +{ + QVBoxLayout* aLayout = new QVBoxLayout(this); + + myTreeView = new QTreeView(this); + aLayout->addWidget(myTreeView); +} + +ModuleBase_WidgetTreeDataSelect::~ModuleBase_WidgetTreeDataSelect() +{ +} + + +QList ModuleBase_WidgetTreeDataSelect::getControls() const +{ + QList aList; + aList << myTreeView; + return aList; +} + +bool ModuleBase_WidgetTreeDataSelect::storeValueCustom() +{ + return true; +} + +bool ModuleBase_WidgetTreeDataSelect::restoreValueCustom() +{ + return true; +} diff --git a/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.h b/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.h new file mode 100644 index 000000000..8f4c8c342 --- /dev/null +++ b/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.h @@ -0,0 +1,63 @@ +// Copyright (C) 2014-2019 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 +// + +#ifndef MODULEBASE_WIDGETTREEDATASELECT_H_ +#define MODULEBASE_WIDGETTREEDATASELECT_H_ + +#include +#include + +class QTreeView; + +/** +* \ingroup GUI +* Implementation of a widget for tree data selection +*/ +class MODULEBASE_EXPORT ModuleBase_WidgetTreeDataSelect : public ModuleBase_ModelWidget +{ + Q_OBJECT +public: + /// Constructor + /// \param theParent the parent object + /// \param theWorkshop a reference to workshop + /// \param theData the widget configuation. The attribute of the model widget is obtained from + ModuleBase_WidgetTreeDataSelect(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, + const Config_WidgetAPI* theData); + + virtual ~ModuleBase_WidgetTreeDataSelect(); + + /// Returns list of widget controls + /// \return a control list + virtual QList getControls() const; + + /// Saves the internal parameters to the given feature + /// \return True in success + virtual bool storeValueCustom(); + + /// Restore value from attribute data to the widget's control + virtual bool restoreValueCustom(); + +protected: + ModuleBase_IWorkshop* myWorkshop; ///< the active workshop + +private: + QTreeView* myTreeView; +}; + +#endif \ No newline at end of file -- 2.39.2