ui: search view autocompletion

- Implemented autocompletion for the QtSearchView.
- Added: MessageFinishedParsing that will be dispatched by the Project after the parsing step is done.
- Moved the initial MessageActivateToken from the Project to the Application.
- Added getNamesForNodesWithNamePrefix() to GraphAccess.
This commit is contained in:
malte_langkabel
2014-07-07 11:25:46 +02:00
parent a70a9009cc
commit c02767362f
18 changed files with 162 additions and 11 deletions
+34 -3
View File
@@ -10,6 +10,8 @@
QtSearchView::QtSearchView(ViewLayout* viewLayout)
: SearchView(viewLayout)
, m_setTextFunctor(std::bind(&QtSearchView::doSetText, this, std::placeholders::_1))
, m_setAutocompletionListFunctor(std::bind(&QtSearchView::doSetAutocompletionList, this, std::placeholders::_1))
{
}
@@ -36,6 +38,11 @@ void QtSearchView::initGui()
m_searchBox->setPlaceholderText("Please enter your search string.");
m_searchBox->setCallbackOnReturnPressed(std::bind(&QtSearchView::onSeachButtonClick, this));
std::vector<std::string> autocompletionList;
autocompletionList.push_back("tralala");
autocompletionList.push_back("lalila");
setAutocompletionList(autocompletionList);
m_searchButton = new QtButton(widget);
m_searchButton->setText("Search");
m_searchButton->setCallbackOnClick(std::bind(&QtSearchView::onSeachButtonClick, this));
@@ -44,7 +51,26 @@ void QtSearchView::initGui()
widget->layout()->addWidget(m_searchButton);
}
void QtSearchView::setText(const std::string& s) const
void QtSearchView::setText(const std::string& s)
{
m_setTextFunctor(s);
}
void QtSearchView::setAutocompletionList(const std::vector<std::string>& autocompletionList)
{
m_setAutocompletionListFunctor(autocompletionList);
}
void QtSearchView::onSeachButtonClick()
{
SearchController* controller = getController();
if (controller)
{
controller->search(m_searchBox->text().toStdString());
}
}
void QtSearchView::doSetText(const std::string& s)
{
if (m_searchBox->text() != s.c_str())
{
@@ -52,7 +78,12 @@ void QtSearchView::setText(const std::string& s) const
}
}
void QtSearchView::onSeachButtonClick()
void QtSearchView::doSetAutocompletionList(const std::vector<std::string>& autocompletionList)
{
getController()->search(m_searchBox->text().toStdString());
QStringList wordList;
for (const std::string& s: autocompletionList)
wordList << s.c_str();
QCompleter *completer = new QCompleter(wordList, m_searchBox);
completer->setCaseSensitivity(Qt::CaseInsensitive);
m_searchBox->setCompleter(completer);
}