Salome HOME
updated copyright message
[modules/shaper.git] / src / ModuleBase / ModuleBase_ParamSpinBox.cpp
index fcfbf29492ff032e510c5d6dc6c697abfe802db6..9c9cc761329f1a34dc7c03becabc4e3864fabac0 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2020  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
@@ -47,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());
@@ -81,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);
 }
 
 /*!