#include <QToolTip>
#include <QApplication>
+#include <QStringListModel>
+#include <QCompleter>
+#include <QShortcut>
+
#include <string>
#include <iostream>
+//#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.
*/
#include <QValidator>
+class QStringListModel;
+class QCompleter;
+
/**
* \ingroup GUI
* An extension of a double spin box which let to use parameters and expressions for value definition
\param thePrecision a precision of values display
*/
explicit ModuleBase_ParamSpinBox( QWidget* theParent = 0, int thePrecision = -12 );
+
+ /// Set list of completion strings
+ void setCompletionList(QStringList&);
+
virtual ~ModuleBase_ParamSpinBox();
virtual void stepBy(int);
/// Returns True if the input value contains variable
bool hasVariable() const;
- protected:
+protected:
/// Returns True if the given text contains variable
/// \param theText a text string
bool hasVariable(const QString& theText) const;
QString myTextValue;
bool myAcceptVariables;
+
+ QStringListModel* myCompleterModel;
+ QCompleter* myCompleter;
};
#endif
#include <iostream>
#endif
+//#define DEBUG_COMPLETE_WITH_PARAMETERS
+
ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
const Config_WidgetAPI* theData)
: ModuleBase_ModelWidget(theParent, theData)
{
}
+void ModuleBase_WidgetDoubleValue::activateCustom()
+{
+ ModuleBase_ModelWidget::activateCustom();
+#ifdef DEBUG_COMPLETE_WITH_PARAMETERS
+ QStringList aParameters;
+ ModuleBase_Tools::getParameters(aParameters);
+ mySpinBox->setCompletionList(aParameters);
+#endif
+}
+
bool ModuleBase_WidgetDoubleValue::resetCustom()
{
bool aDone = false;
virtual ~ModuleBase_WidgetDoubleValue();
+ /// The methiod called when widget is activated
+ virtual void activateCustom();
+
/// Select the internal content if it can be selected. It is empty in the default realization
virtual void selectContent();