+ myCompleter = new QCompleter(this);
+ myCompleter->setWidget(lineEdit());
+ myCompleter->setCompletionMode(QCompleter::PopupCompletion);
+
+ myCompleterModel = new QStringListModel(this);
+ myCompleter->setModel(myCompleterModel);
+ connect(myCompleter, SIGNAL(highlighted(const QString&)),
+ this, SLOT(insertCompletion(const QString&)));
+
+ QAbstractItemView* aPopup = myCompleter->popup();
+ aPopup->installEventFilter(this);
+
+ // connectSignalsAndSlots();
+ myEnabledBaseColor = palette().color(QPalette::Active, QPalette::Base);
+ connect(lineEdit(), SIGNAL(textChanged(const QString&)),
+ this, SLOT(onTextChanged(const QString&)));
+
+ setLocale(QLocale::c());
+
+ myValidator = new QDoubleValidator(this);
+ myValidator->setLocale(locale());
+ myValidator->setRange(myMinimum, myMaximum);
+ myValidator->setDecimals(thePrecision);
+}
+
+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);