From: nds Date: Fri, 18 Mar 2016 04:41:26 +0000 (+0300) Subject: Double value control improved, the improvement is currently commented. X-Git-Tag: V_2.3.0~375 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8df398a914d768c5625808a7aa8ed504461f8b2a;p=modules%2Fshaper.git Double value control improved, the improvement is currently commented. --- diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index 40b50fb17..f559eb68a 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -13,17 +13,45 @@ #include #include +#include +#include +#include + #include #include +//#define DEBUG_COMPLETE_WITH_PARAMETERS ModuleBase_ParamSpinBox::ModuleBase_ParamSpinBox(QWidget* theParent, int thePrecision) : ModuleBase_DoubleSpinBox(theParent, thePrecision), myAcceptVariables(true) { +#ifdef DEBUG_COMPLETE_WITH_PARAMETERS + myCompleter = new QCompleter(this); + myCompleter->setWidget(this); + myCompleter->setCompletionMode(QCompleter::PopupCompletion); + + myCompleterModel = new QStringListModel(this); + myCompleter->setModel(myCompleterModel); + // Use sorted model to accelerate completion (QCompleter will use binary search) + myCompleter->setModelSorting(QCompleter::CaseInsensitivelySortedModel); + myCompleter->setCaseSensitivity(Qt::CaseInsensitive); + + lineEdit()->setCompleter(myCompleter); +#endif + connectSignalsAndSlots(); } +void ModuleBase_ParamSpinBox::setCompletionList(QStringList& theList) +{ +#ifdef DEBUG_COMPLETE_WITH_PARAMETERS + theList.sort(); + theList.removeDuplicates(); + myCompleterModel->setStringList(theList); +#endif +} + /*! \brief Destructor. */ diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.h b/src/ModuleBase/ModuleBase_ParamSpinBox.h index 591d0cfd9..6f2252ec8 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.h +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.h @@ -8,6 +8,9 @@ #include +class QStringListModel; +class QCompleter; + /** * \ingroup GUI * An extension of a double spin box which let to use parameters and expressions for value definition @@ -30,6 +33,10 @@ public: \param thePrecision a precision of values display */ explicit ModuleBase_ParamSpinBox( QWidget* theParent = 0, int thePrecision = -12 ); + + /// Set list of completion strings + void setCompletionList(QStringList&); + virtual ~ModuleBase_ParamSpinBox(); virtual void stepBy(int); @@ -52,7 +59,7 @@ public: /// Returns True if the input value contains variable bool hasVariable() const; - protected: +protected: /// Returns True if the given text contains variable /// \param theText a text string bool hasVariable(const QString& theText) const; @@ -82,6 +89,9 @@ public: QString myTextValue; bool myAcceptVariables; + + QStringListModel* myCompleterModel; + QCompleter* myCompleter; }; #endif diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 672539acb..fa4e22c18 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -31,6 +31,8 @@ #include #endif +//#define DEBUG_COMPLETE_WITH_PARAMETERS + ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData) : ModuleBase_ModelWidget(theParent, theData) @@ -95,6 +97,16 @@ ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue() { } +void ModuleBase_WidgetDoubleValue::activateCustom() +{ + ModuleBase_ModelWidget::activateCustom(); +#ifdef DEBUG_COMPLETE_WITH_PARAMETERS + QStringList aParameters; + ModuleBase_Tools::getParameters(aParameters); + mySpinBox->setCompletionList(aParameters); +#endif +} + bool ModuleBase_WidgetDoubleValue::resetCustom() { bool aDone = false; diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h index 0abf5b526..e77b17cc3 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h @@ -35,6 +35,9 @@ Q_OBJECT virtual ~ModuleBase_WidgetDoubleValue(); + /// The methiod called when widget is activated + virtual void activateCustom(); + /// Select the internal content if it can be selected. It is empty in the default realization virtual void selectContent();