Salome HOME
updated copyright message
[modules/shaper.git] / src / ModuleBase / ModuleBase_ParamSpinBox.cpp
index 941a2e2cf0e359990ca18a23077d957e37e602b7..9c9cc761329f1a34dc7c03becabc4e3864fabac0 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // 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
+// 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>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "ModuleBase_ParamSpinBox.h"
@@ -48,9 +47,9 @@ ModuleBase_ParamSpinBox::ModuleBase_ParamSpinBox(QWidget* theParent, int thePrec
   : QAbstractSpinBox(theParent),
   myIsEquation(false),
   myAcceptVariables(true),
-  mySingleStep(1),
   myMinimum(-DBL_MAX),
-  myMaximum(DBL_MAX)
+  myMaximum(DBL_MAX),
+  mySingleStep(1)
 {
   myCompleter = new QCompleter(this);
   myCompleter->setWidget(lineEdit());
@@ -82,6 +81,17 @@ void ModuleBase_ParamSpinBox::setCompletionList(QStringList& theList)
   theList.removeDuplicates();
   theList.sort();
   myCompleterModel->setStringList(theList);
+
+  QAbstractItemView* aPopup = myCompleter->popup();
+  QFontMetrics aMetric = aPopup->fontMetrics();
+  int aWidth = 0;
+  QRect aRect;
+  foreach(QString aStr, theList) {
+    aRect = aMetric.boundingRect(aStr);
+    if (aRect.width() > aWidth)
+      aWidth = aRect.width();
+  }
+  aPopup->setMinimumWidth(aWidth + 25);
 }
 
 /*!
@@ -162,7 +172,6 @@ void ModuleBase_ParamSpinBox::setValue(double value)
 
 double ModuleBase_ParamSpinBox::value() const
 {
-  std::string aa = lineEdit()->text().toStdString();
   return lineEdit()->text().toDouble();
 }