X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ParamSpinBox.cpp;h=c42e163b84f8c9331a28347fc890ee8f5b4067fc;hb=d75b1b5c09b57fd8326d846118fa3246a9857492;hp=bfd0823866a868242e6e83567dd7933792166e2d;hpb=3b6472899555f2186d09f45f4f1fde38b3af969a;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index bfd082386..c42e163b8 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -1,7 +1,10 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + #include "ModuleBase_ParamSpinBox.h" #include #include +#include #include #include #include @@ -13,17 +16,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. */ @@ -60,6 +91,7 @@ void ModuleBase_ParamSpinBox::connectSignalsAndSlots() void ModuleBase_ParamSpinBox::onTextChanged(const QString& text) { myTextValue = text; + emit textChanged(text); } double ModuleBase_ParamSpinBox::valueFromText(const QString& theText) const @@ -67,7 +99,7 @@ double ModuleBase_ParamSpinBox::valueFromText(const QString& theText) const if (!hasVariable(theText)) return ModuleBase_DoubleSpinBox::valueFromText(theText); - // small hack: return length of the string to initiate valuesChanged signal + // small hack: return hash of the string to initiate valuesChanged signal return qHash(theText); } @@ -101,9 +133,14 @@ QValidator::State ModuleBase_ParamSpinBox::validate(QString& str, int& pos) cons /*! \brief This function is used to set a current value for this spinbox. \param value current value + + The new value is ignored if the spinbox has a variable. */ void ModuleBase_ParamSpinBox::setValue(const double value) { + if (hasVariable()) + return; + myTextValue = ModuleBase_DoubleSpinBox::textFromValue(value); ModuleBase_DoubleSpinBox::setValue(value); } @@ -210,11 +247,11 @@ bool ModuleBase_ParamSpinBox::findVariable(const QString& theName, double& outValue) const { ResultParameterPtr aParam; - return ModelAPI_Tools::findVariable(theName.toStdString(), outValue, aParam); + return ModelAPI_Tools::findVariable(FeaturePtr(), theName.toStdString(), outValue, aParam); } /*! - \brief This function is called when the spinbox recieves key press event. + \brief This function is called when the spinbox receives key press event. */ //void ModuleBase_ParamSpinBox::keyPressEvent(QKeyEvent* e) //{ @@ -226,7 +263,7 @@ bool ModuleBase_ParamSpinBox::findVariable(const QString& theName, //} /*! - \brief This function is called when the spinbox recieves show event. + \brief This function is called when the spinbox receives show event. */ void ModuleBase_ParamSpinBox::showEvent(QShowEvent* theEvent) {