mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Use a proper filter bar in the outliner
This commit is contained in:
parent
2a8cac75f4
commit
1205018286
@ -42,7 +42,7 @@ public:
|
||||
bool initialiseParams(std::string const & data) override;
|
||||
void updateView() override;
|
||||
void enableView(bool enable) override;
|
||||
bool wantInitialFocus() const override { return false; }
|
||||
bool wantInitialFocus() const override { return true; }
|
||||
void closeEvent(QCloseEvent * event) override;
|
||||
bool isClosing() const override { return is_closing_; }
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "GuiView.h"
|
||||
#include "qt_helpers.h"
|
||||
#include "TocModel.h"
|
||||
#include "FancyLineEdit.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferView.h"
|
||||
@ -77,11 +78,18 @@ TocWidget::TocWidget(GuiView & gui_view, QWidget * parent)
|
||||
|
||||
// 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);
|
||||
@ -92,8 +100,15 @@ TocWidget::TocWidget(GuiView & gui_view, QWidget * parent)
|
||||
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()));
|
||||
|
||||
@ -521,7 +536,7 @@ void TocWidget::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());
|
||||
|
@ -34,6 +34,7 @@ class Inset;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
class FancyLineEdit;
|
||||
class GuiView;
|
||||
|
||||
class TocWidget : public QWidget, public Ui::TocUi
|
||||
@ -118,6 +119,8 @@ private:
|
||||
GuiView & gui_view_;
|
||||
// Timer for scheduling expensive update operations
|
||||
QTimer * timer_;
|
||||
/// Filter bar
|
||||
FancyLineEdit * filter_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -342,17 +342,7 @@
|
||||
<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>
|
||||
@ -369,6 +359,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="filterBarL"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user