Files
Sourcetrail/src/app/qt/element/QtSearchBar.cpp
T
Eberhard Graether 8242454104 ui/data: cleaned up UI and parsing
* HOT FIX: typename not always correctly split to name hierarchy
* show node main if available as first active token after parsing
* show all contents of namespaces if searched for
* added missing enum type and enum value usages
* added inheritance for structs
* removed MessageActivateToken and replaced it with MessageActivateTokens
* activating correct nodes for clicks in GraphView and CodeView
* no graph change when clicking an edge, but highlighting the edge instead
* only show active nodes without connections when multiple are activated
* fixed snippet sorting to put file that contains declarations on top
* set sizeHints on CodeView and SearchView to increase their initial size

fortune cookie message = Das Leben wird eine positive Wendung nehmen.
2015-01-08 12:12:50 +01:00

83 lines
2.4 KiB
C++

#include "qt/element/QtSearchBar.h"
#include <QCompleter>
#include <QHBoxLayout>
#include <QPushButton>
#include "qt/element/QtSmartSearchBox.h"
QtSearchBar::QtSearchBar()
{
setObjectName("search_bar");
QBoxLayout* layout = new QHBoxLayout();
layout->setSpacing(0);
layout->setAlignment(Qt::AlignTop);
setLayout(layout);
m_searchBoxContainer = new QWidget(this);
m_searchBoxContainer->setObjectName("search_box_container");
m_searchBoxContainer->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_searchBoxContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
layout->addWidget(m_searchBoxContainer);
QBoxLayout* innerLayout = new QHBoxLayout();
innerLayout->setContentsMargins(7, 3, 5, 3);
m_searchBoxContainer->setLayout(innerLayout);
m_searchBox = new QtSmartSearchBox(m_searchBoxContainer);
m_searchBox->setObjectName("search_box");
m_searchBox->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_searchBox->setAttribute(Qt::WA_MacShowFocusRect, 0); // remove blue focus box on Mac
m_searchBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
innerLayout->addWidget(m_searchBox);
m_searchButton = new QPushButton(this);
m_searchButton->setObjectName("search_button");
m_searchButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_searchButton->setIcon(QIcon("data/gui/search_view/images/search.png"));
layout->addWidget(m_searchButton);
// m_caseSensitiveButton = new QPushButton(this);
// m_caseSensitiveButton->setObjectName("case_sensitive_button");
// m_caseSensitiveButton->setCheckable(true);
// m_caseSensitiveButton->setToolTip("case sensitive");
// m_caseSensitiveButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
// layout->addWidget(m_caseSensitiveButton);
connect(m_searchButton, SIGNAL(clicked()), m_searchBox, SLOT(search()));
}
QtSearchBar::~QtSearchBar()
{
}
QSize QtSearchBar::sizeHint() const
{
return QSize(400, 100);
}
void QtSearchBar::setText(const std::string& text)
{
m_searchBox->setQuery(text);
}
void QtSearchBar::setFocus()
{
m_searchBox->setFocus();
}
void QtSearchBar::setAutocompletionList(const std::vector<SearchMatch>& autocompletionList)
{
m_searchBox->setAutocompletionList(autocompletionList);
}
QAbstractItemView* QtSearchBar::getCompleterPopup()
{
if (m_searchBox->completer())
{
return m_searchBox->completer()->popup();
}
return nullptr;
}