#include "GuiView.h"
#include "qt_helpers.h"
#include "TocModel.h"
+#include "FancyLineEdit.h"
#include "Buffer.h"
#include "BufferView.h"
// Only one item selected at a time.
tocTV->setSelectionMode(QAbstractItemView::SingleSelection);
- setFocusProxy(tocTV);
// The toc types combo won't change its model.
typeCO->setModel(gui_view_.tocModels().nameModel());
+ // The filter bar
+ filter_ = new FancyLineEdit(this);
+ filter_->setClearButton(true);
+ filter_->setPlaceholderText(qt_("All items"));
+ filterBarL->addWidget(filter_, 0);
+ filterLA->setBuddy(filter_);
+ setFocusProxy(filter_);
+
// Make sure the buttons are disabled when first shown without a loaded
// Buffer.
enableControls(false);
this, SLOT(showContextMenu(const QPoint &)));
connect(tocTV, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showContextMenu(const QPoint &)));
- connect(filterLE, SIGNAL(textEdited(QString)),
+ connect(filter_, SIGNAL(textEdited(QString)),
this, SLOT(filterContents()));
+#if (QT_VERSION < 0x050000)
+ connect(filter_, SIGNAL(downPressed()),
+ tocTV, SLOT(setFocus()));
+#else
+ connect(filter_, &FancyLineEdit::downPressed,
+ tocTV, [this](){ focusAndHighlight(tocTV); });
+#endif
connect(activeFilterCO, SIGNAL(activated(int)),
this, SLOT(filterContents()));
QModelIndex index = indices[i];
bool matches =
index.data().toString().contains(
- filterLE->text(), Qt::CaseInsensitive);
+ filter_->text(), Qt::CaseInsensitive);
TocItem const & item =
gui_view_.tocModels().currentItem(current_type_, index);
matches &= (show_active && item.isOutput()) || (show_inactive && !item.isOutput());
<item row="2" column="0">
<widget class="QLabel" name="filterLA">
<property name="text">
- <string>Filter:</string>
- </property>
- <property name="buddy">
- <cstring>filterLE</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLineEdit" name="filterLE">
- <property name="toolTip">
- <string>Enter string to filter contents</string>
+ <string>&Filter:</string>
</property>
</widget>
</item>
</property>
</widget>
</item>
+ <item row="2" column="1">
+ <layout class="QHBoxLayout" name="filterBarL"/>
+ </item>
</layout>
</item>
</layout>