87 lines
1.9 KiB
C++
87 lines
1.9 KiB
C++
#include "qt/view/QtSearchView.h"
|
|
|
|
#include "qt/utility/utilityQt.h"
|
|
|
|
#include "component/controller/SearchController.h"
|
|
#include "qt/view/QtViewWidgetWrapper.h"
|
|
|
|
QtSearchView::QtSearchView(ViewLayout* viewLayout)
|
|
: SearchView(viewLayout)
|
|
, m_refreshViewFunctor(std::bind(&QtSearchView::doRefreshView, this))
|
|
, m_setMatchesFunctor(std::bind(&QtSearchView::doSetMatches, this, std::placeholders::_1))
|
|
, m_setFocusFunctor(std::bind(&QtSearchView::doSetFocus, this))
|
|
, m_setAutocompletionListFunctor(std::bind(&QtSearchView::doSetAutocompletionList, this, std::placeholders::_1))
|
|
{
|
|
m_widget = new QtSearchBar();
|
|
setStyleSheet();
|
|
}
|
|
|
|
QtSearchView::~QtSearchView()
|
|
{
|
|
}
|
|
|
|
void QtSearchView::createWidgetWrapper()
|
|
{
|
|
setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(m_widget));
|
|
}
|
|
|
|
void QtSearchView::initView()
|
|
{
|
|
}
|
|
|
|
void QtSearchView::refreshView()
|
|
{
|
|
m_refreshViewFunctor();
|
|
}
|
|
|
|
void QtSearchView::setMatches(const std::vector<SearchMatch>& matches)
|
|
{
|
|
m_setMatchesFunctor(matches);
|
|
}
|
|
|
|
void QtSearchView::setFocus()
|
|
{
|
|
m_setFocusFunctor();
|
|
}
|
|
|
|
void QtSearchView::setAutocompletionList(const std::vector<SearchMatch>& autocompletionList)
|
|
{
|
|
m_setAutocompletionListFunctor(autocompletionList);
|
|
}
|
|
|
|
void QtSearchView::doRefreshView()
|
|
{
|
|
setStyleSheet();
|
|
m_widget->refreshStyle();
|
|
m_widget->setMatches(std::vector<SearchMatch>());
|
|
}
|
|
|
|
void QtSearchView::doSetMatches(const std::vector<SearchMatch>& matches)
|
|
{
|
|
m_widget->setMatches(matches);
|
|
}
|
|
|
|
void QtSearchView::doSetFocus()
|
|
{
|
|
getViewLayout()->showView(this);
|
|
m_widget->setFocus();
|
|
}
|
|
|
|
void QtSearchView::doSetAutocompletionList(const std::vector<SearchMatch>& autocompletionList)
|
|
{
|
|
m_widget->setAutocompletionList(autocompletionList);
|
|
setStyleSheet();
|
|
}
|
|
|
|
void QtSearchView::setStyleSheet()
|
|
{
|
|
std::string css = utility::getStyleSheet("data/gui/search_view/search_view.css");
|
|
|
|
m_widget->setStyleSheet(css.c_str());
|
|
|
|
if (m_widget->getCompleterPopup())
|
|
{
|
|
m_widget->getCompleterPopup()->setStyleSheet(css.c_str());
|
|
}
|
|
}
|