Commit 82a0f55b authored by hjk's avatar hjk

Find: Add a convenience "factory" for searchable treeview wrappers

Change-Id: I19890dd13d597ca71c134db7b036fa1ade0d5b5a
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 11a2d3dc
......@@ -29,9 +29,13 @@
#include "treeviewfind.h"
#include <QTreeView>
#include <QTextCursor>
#include <aggregation/aggregate.h>
#include <coreplugin/findplaceholder.h>
#include <QModelIndex>
#include <QTextCursor>
#include <QTreeView>
#include <QVBoxLayout>
namespace Core {
......@@ -126,6 +130,22 @@ IFindSupport::Result TreeViewFind::findStep(const QString &txt, FindFlags findFl
return result;
}
QWidget *TreeViewFind::createSearchableWrapper(QTreeView *treeView)
{
QWidget *widget = new QWidget;
QVBoxLayout *vbox = new QVBoxLayout(widget);
vbox->setMargin(0);
vbox->setSpacing(0);
vbox->addWidget(treeView);
vbox->addWidget(new Core::FindToolBarPlaceHolder(widget));
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(treeView);
agg->add(new TreeViewFind(treeView));
return widget;
}
IFindSupport::Result TreeViewFind::find(const QString &searchTxt,
FindFlags findFlags,
bool startFromCurrentIndex,
......
......@@ -58,6 +58,8 @@ public:
Result findIncremental(const QString &txt, FindFlags findFlags);
Result findStep(const QString &txt, FindFlags findFlags);
static QWidget *createSearchableWrapper(QTreeView *treeView);
private:
Result find(const QString &txt, FindFlags findFlags,
bool startFromCurrentIndex, bool *wrapped);
......
......@@ -74,6 +74,7 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/find/treeviewfind.h>
#include <coreplugin/imode.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
......@@ -125,10 +126,6 @@
#include <QTreeWidget>
#include <QVBoxLayout>
#include <aggregation/aggregate.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/find/treeviewfind.h>
#ifdef WITH_TESTS
#include <QTest>
#include <QSignalSpy>
......@@ -535,8 +532,6 @@ public:
static QWidget *addSearch(BaseTreeView *treeView, const QString &title, const char *objectName)
{
QWidget *widget = new QWidget;
QAction *act = debuggerCore()->action(UseAlternatingRowColors);
treeView->setAlternatingRowColors(act->isChecked());
QObject::connect(act, SIGNAL(toggled(bool)),
......@@ -547,19 +542,9 @@ static QWidget *addSearch(BaseTreeView *treeView, const QString &title, const ch
QObject::connect(act, SIGNAL(toggled(bool)),
treeView, SLOT(setAlwaysAdjustColumns(bool)));
QVBoxLayout *vbox = new QVBoxLayout(widget);
vbox->setMargin(0);
vbox->setSpacing(0);
vbox->addWidget(treeView);
vbox->addWidget(new Core::FindToolBarPlaceHolder(widget));
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(treeView);
agg->add(new Core::TreeViewFind(treeView));
QWidget *widget = TreeViewFind::createSearchableWrapper(treeView);
widget->setObjectName(QLatin1String(objectName));
widget->setWindowTitle(title);
return widget;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment