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 @@ ...@@ -29,9 +29,13 @@
#include "treeviewfind.h" #include "treeviewfind.h"
#include <QTreeView> #include <aggregation/aggregate.h>
#include <QTextCursor> #include <coreplugin/findplaceholder.h>
#include <QModelIndex> #include <QModelIndex>
#include <QTextCursor>
#include <QTreeView>
#include <QVBoxLayout>
namespace Core { namespace Core {
...@@ -126,6 +130,22 @@ IFindSupport::Result TreeViewFind::findStep(const QString &txt, FindFlags findFl ...@@ -126,6 +130,22 @@ IFindSupport::Result TreeViewFind::findStep(const QString &txt, FindFlags findFl
return result; 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, IFindSupport::Result TreeViewFind::find(const QString &searchTxt,
FindFlags findFlags, FindFlags findFlags,
bool startFromCurrentIndex, bool startFromCurrentIndex,
......
...@@ -58,6 +58,8 @@ public: ...@@ -58,6 +58,8 @@ public:
Result findIncremental(const QString &txt, FindFlags findFlags); Result findIncremental(const QString &txt, FindFlags findFlags);
Result findStep(const QString &txt, FindFlags findFlags); Result findStep(const QString &txt, FindFlags findFlags);
static QWidget *createSearchableWrapper(QTreeView *treeView);
private: private:
Result find(const QString &txt, FindFlags findFlags, Result find(const QString &txt, FindFlags findFlags,
bool startFromCurrentIndex, bool *wrapped); bool startFromCurrentIndex, bool *wrapped);
......
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/find/treeviewfind.h>
#include <coreplugin/imode.h> #include <coreplugin/imode.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
...@@ -125,10 +126,6 @@ ...@@ -125,10 +126,6 @@
#include <QTreeWidget> #include <QTreeWidget>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <aggregation/aggregate.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/find/treeviewfind.h>
#ifdef WITH_TESTS #ifdef WITH_TESTS
#include <QTest> #include <QTest>
#include <QSignalSpy> #include <QSignalSpy>
...@@ -535,8 +532,6 @@ public: ...@@ -535,8 +532,6 @@ public:
static QWidget *addSearch(BaseTreeView *treeView, const QString &title, const char *objectName) static QWidget *addSearch(BaseTreeView *treeView, const QString &title, const char *objectName)
{ {
QWidget *widget = new QWidget;
QAction *act = debuggerCore()->action(UseAlternatingRowColors); QAction *act = debuggerCore()->action(UseAlternatingRowColors);
treeView->setAlternatingRowColors(act->isChecked()); treeView->setAlternatingRowColors(act->isChecked());
QObject::connect(act, SIGNAL(toggled(bool)), QObject::connect(act, SIGNAL(toggled(bool)),
...@@ -547,19 +542,9 @@ static QWidget *addSearch(BaseTreeView *treeView, const QString &title, const ch ...@@ -547,19 +542,9 @@ static QWidget *addSearch(BaseTreeView *treeView, const QString &title, const ch
QObject::connect(act, SIGNAL(toggled(bool)), QObject::connect(act, SIGNAL(toggled(bool)),
treeView, SLOT(setAlwaysAdjustColumns(bool))); treeView, SLOT(setAlwaysAdjustColumns(bool)));
QVBoxLayout *vbox = new QVBoxLayout(widget); QWidget *widget = TreeViewFind::createSearchableWrapper(treeView);
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));
widget->setObjectName(QLatin1String(objectName)); widget->setObjectName(QLatin1String(objectName));
widget->setWindowTitle(title); widget->setWindowTitle(title);
return widget; 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