ui: basic search view

- Added a basic SearchView (+ controller and qt implementation)
- SearchView can set the active element of other views by dispatching a message.
- SearchView adjusts its text when the active element is changed by other views.
- Added wrappers for Button and EditBox that allow the usage of simple callback functions.
This commit is contained in:
malte_langkabel
2014-07-04 13:43:27 +02:00
parent 9297ea6d6d
commit b1023ba4ac
22 changed files with 356 additions and 6 deletions
+58
View File
@@ -0,0 +1,58 @@
#include "qt/view/QtSearchView.h"
#include <QtWidgets>
#include "qt/element/QtButton.h"
#include "qt/element/QtEditBox.h"
#include "qt/QtWidgetWrapper.h"
#include "qt/utility/utilityQt.h"
#include "component/controller/SearchController.h"
QtSearchView::QtSearchView(ViewLayout* viewLayout)
: SearchView(viewLayout)
{
}
QtSearchView::~QtSearchView()
{
}
void QtSearchView::createWidgetWrapper()
{
setWidgetWrapper(std::make_shared<QtWidgetWrapper>(std::make_shared<QFrame>()));
}
void QtSearchView::initGui()
{
QWidget* widget = QtWidgetWrapper::getWidgetOfView(this);
utility::setWidgetBackgroundColor(widget, Colori(190, 190, 190, 255));
QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight);
layout->setSpacing(3);
layout->setContentsMargins(3, 3, 3, 3);
widget->setLayout(layout);
m_searchBox = new QtEditBox(widget);
m_searchBox->setPlaceholderText("Please enter your search string.");
m_searchBox->setCallbackOnReturnPressed(std::bind(&QtSearchView::onSeachButtonClick, this));
m_searchButton = new QtButton(widget);
m_searchButton->setText("Search");
m_searchButton->setCallbackOnClick(std::bind(&QtSearchView::onSeachButtonClick, this));
widget->layout()->addWidget(m_searchBox);
widget->layout()->addWidget(m_searchButton);
}
void QtSearchView::setText(const std::string& s) const
{
if (m_searchBox->text() != s.c_str())
{
m_searchBox->setText(s.c_str());
}
}
void QtSearchView::onSeachButtonClick()
{
getController()->search(m_searchBox->text().toStdString());
}