diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/CMakeLists.txt b/source/ArmarXGui/libraries/ArmarXGuiBase/CMakeLists.txt index 84fbb67b84e631daeb1c1818a11649443e510efa..7ee147a75de93c98bf9d5b050770e7a3e2cdae32 100644 --- a/source/ArmarXGui/libraries/ArmarXGuiBase/CMakeLists.txt +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/CMakeLists.txt @@ -37,6 +37,7 @@ set(LIB_FILES ArmarXWidgetController.cpp widgets/cpp-markdown/markdown-tokens.cpp widgets/TipDialog.cpp widgets/InfixFilterModel.cpp + widgets/InfixCompleter.cpp ) set(LIB_HEADERS ArmarXGuiInterface.h @@ -54,6 +55,7 @@ set(LIB_HEADERS ArmarXGuiInterface.h widgets/cpp-markdown/markdown-tokens.h widgets/TipDialog.h widgets/InfixFilterModel.h + widgets/InfixCompleter.h ) set(GUI_UIS @@ -77,6 +79,7 @@ qt4_wrap_cpp(LIB_FILES widgets/MarkdownEditor.h widgets/TipDialog.h widgets/InfixFilterModel.h + widgets/InfixCompleter.h ) qt4_wrap_ui(UI_HEADER ${GUI_UIS}) diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/InfixCompleter.cpp b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/InfixCompleter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..54b6cc8a1e603a6858889585edda0791ab8374d8 --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/InfixCompleter.cpp @@ -0,0 +1,43 @@ +#include "InfixCompleter.h" +#include "InfixFilterModel.h" + +#include <QListView> +#include <QStringListModel> + +namespace armarx +{ + + InfixCompleter::InfixCompleter(const QStringList& completionList, QObject* parent) : QCompleter(parent) + { + QListView* popup = new QListView(); + completionModel = new QStringListModel(completionList, this); + proxyModel = new InfixFilterModel(); + proxyModel->setSourceModel(completionModel); + setModel(proxyModel); + setPopup(popup); + setCaseSensitivity(Qt::CaseInsensitive); + } + + void InfixCompleter::setCompletionList(const QStringList& completionList) + { + completionModel->setStringList(completionList); + } + + InfixFilterModel* InfixCompleter::getProxyModel() const + { + return proxyModel; + } + + QStringList InfixCompleter::splitPath(const QString& path) const + { + return QStringList(""); + } + + void InfixCompleter::setCompletionInfix(const QString& infix) + { + proxyModel->setFilterFixedString(infix); + } + + + +} diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/InfixCompleter.h b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/InfixCompleter.h new file mode 100644 index 0000000000000000000000000000000000000000..706c1aaf53dcc1898d9375245087495eb614bcc3 --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/InfixCompleter.h @@ -0,0 +1,36 @@ +#ifndef _H_ARMARX_INFIXCOMPLETER_H +#define _H_ARMARX_INFIXCOMPLETER_H + +#include <QCompleter> +#include <QObject> + +class QStringListModel; + +namespace armarx +{ + class InfixFilterModel; + + /** + * @brief This class changes the standard QCompleter to an infix match completer. + */ + class InfixCompleter : public QCompleter + { + Q_OBJECT + + // QCompleter interface + public: + InfixCompleter(const QStringList& completionList, QObject* parent = 0); + void setCompletionList(const QStringList& completionList); + InfixFilterModel* getProxyModel() const; + QStringList splitPath(const QString& path) const; + public slots: + void setCompletionInfix(const QString& infix); + protected: + InfixFilterModel* proxyModel; + QStringListModel* completionModel; + }; + + +} + +#endif