diff --git a/src/Gui/DlgPropertyLink.cpp b/src/Gui/DlgPropertyLink.cpp index 4c510f0272b0..83a81b259c04 100644 --- a/src/Gui/DlgPropertyLink.cpp +++ b/src/Gui/DlgPropertyLink.cpp @@ -76,6 +76,7 @@ DlgPropertyLink::DlgPropertyLink(QWidget* parent) ui->typeTree->hide(); ui->searchBox->installEventFilter(this); ui->searchBox->setNoProperty(true); + ui->searchBox->setMatchExact(false); timer = new QTimer(this); timer->setSingleShot(true); diff --git a/src/Gui/ExpressionCompleter.cpp b/src/Gui/ExpressionCompleter.cpp index 0c377627b68c..66e29a895747 100644 --- a/src/Gui/ExpressionCompleter.cpp +++ b/src/Gui/ExpressionCompleter.cpp @@ -537,7 +537,11 @@ ExpressionLineEdit::ExpressionLineEdit(QWidget *parent, bool noProperty) , block(true) , noProperty(noProperty) { - connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(slotTextChanged(const QString&))); + auto handle = GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Expression"); + matchExact = handle->GetBool("CompleterMatchExact", false); + + connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(slotTextChanged(const QString&))); } void ExpressionLineEdit::setDocumentObject(const App::DocumentObject * currentDocObj) @@ -550,6 +554,10 @@ void ExpressionLineEdit::setDocumentObject(const App::DocumentObject * currentDo completer = new ExpressionCompleter(currentDocObj, this, noProperty); completer->setWidget(this); completer->setCaseSensitivity(Qt::CaseInsensitive); +#if QT_VERSION>=QT_VERSION_CHECK(5,2,0) + if (!matchExact) + completer->setFilterMode(Qt::MatchContains); +#endif connect(completer, SIGNAL(activated(QString)), this, SLOT(slotCompleteText(QString))); connect(completer, SIGNAL(highlighted(QString)), this, SLOT(slotCompleteText(QString))); connect(this, SIGNAL(textChanged2(QString,int)), completer, SLOT(slotUpdate(QString,int))); @@ -562,6 +570,14 @@ void ExpressionLineEdit::setNoProperty(bool enabled) { completer->setNoProperty(enabled); } +void ExpressionLineEdit::setMatchExact(bool enabled) { + matchExact = enabled; +#if QT_VERSION>=QT_VERSION_CHECK(5,2,0) + if (completer) + completer->setFilterMode(matchExact ? Qt::MatchExactly : Qt::MatchContains); +#endif +} + bool ExpressionLineEdit::completerActive() const { return completer && completer->popup() && completer->popup()->isVisible(); @@ -607,9 +623,21 @@ ExpressionTextEdit::ExpressionTextEdit(QWidget *parent) , completer(0) , block(true) { + auto handle = GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Expression"); + matchExact = handle->GetBool("CompleterMatchExact", false); + connect(this, SIGNAL(textChanged()), this, SLOT(slotTextChanged())); } +void ExpressionTextEdit::setMatchExact(bool enabled) { + matchExact = enabled; +#if QT_VERSION>=QT_VERSION_CHECK(5,2,0) + if (completer) + completer->setFilterMode(matchExact ? Qt::MatchExactly : Qt::MatchContains); +#endif +} + void ExpressionTextEdit::setDocumentObject(const App::DocumentObject * currentDocObj) { if (completer) { @@ -619,6 +647,10 @@ void ExpressionTextEdit::setDocumentObject(const App::DocumentObject * currentDo if (currentDocObj != 0) { completer = new ExpressionCompleter(currentDocObj, this); +#if QT_VERSION>=QT_VERSION_CHECK(5,2,0) + if (!matchExact) + completer->setFilterMode(Qt::MatchContains); +#endif completer->setWidget(this); completer->setCaseSensitivity(Qt::CaseInsensitive); connect(completer, SIGNAL(activated(QString)), this, SLOT(slotCompleteText(QString))); diff --git a/src/Gui/ExpressionCompleter.h b/src/Gui/ExpressionCompleter.h index df75a4ccdfa1..e0062effd294 100644 --- a/src/Gui/ExpressionCompleter.h +++ b/src/Gui/ExpressionCompleter.h @@ -68,6 +68,7 @@ class GuiExport ExpressionLineEdit : public QLineEdit { bool completerActive() const; void hideCompleter(); void setNoProperty(bool enabled=true); + void setMatchExact(bool enabled=true); Q_SIGNALS: void textChanged2(QString text, int pos); public Q_SLOTS: @@ -79,6 +80,7 @@ public Q_SLOTS: ExpressionCompleter * completer; bool block; bool noProperty; + bool matchExact; }; class GuiExport ExpressionTextEdit : public QPlainTextEdit { @@ -88,6 +90,7 @@ class GuiExport ExpressionTextEdit : public QPlainTextEdit { void setDocumentObject(const App::DocumentObject *currentDocObj); bool completerActive() const; void hideCompleter(); + void setMatchExact(bool enabled=true); protected: void keyPressEvent(QKeyEvent * event); Q_SIGNALS: @@ -98,6 +101,7 @@ public Q_SLOTS: private: ExpressionCompleter * completer; bool block; + bool matchExact; }; } diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 3b6fdf16401e..83e067d755f1 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -2838,6 +2838,7 @@ TreePanel::TreePanel(const char *name, QWidget* parent) this, SLOT(showEditor())); this->searchBox = new Gui::ExpressionLineEdit(this,true); + static_cast(this->searchBox)->setMatchExact(false); pLayout->addWidget(this->searchBox); this->searchBox->hide(); this->searchBox->installEventFilter(this);