X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ParamSpinBox.cpp;h=9916aec514e9e907f594822ea431d064321fc2ce;hb=811681738727583c29043cd55903fb71cec19038;hp=43ffd34008e9576021e0a6dd5991187280759b73;hpb=24f9658d6e124a268c6a3abcf24f07aa2dc6d268;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index 43ffd3400..9916aec51 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. */ @@ -67,7 +95,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); } @@ -215,11 +243,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) //{ @@ -231,7 +259,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) {