forked from qt-creator/qt-creator
TreeViewFind -> ItemViewFind
The code changes to enable this is minimal. Change-Id: Ia5571adcc724e89eb5c68a5f91e38b9cf274516d Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
#include "classviewutils.h"
|
||||
#include "classviewconstants.h"
|
||||
|
||||
#include <coreplugin/find/treeviewfind.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <utils/navigationtreeview.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -98,8 +98,8 @@ NavigationWidget::NavigationWidget(QWidget *parent) :
|
||||
verticalLayout->setContentsMargins(0, 0, 0, 0);
|
||||
treeView = new ::Utils::NavigationTreeView(this);
|
||||
treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
verticalLayout->addWidget(Core::TreeViewFind::createSearchableWrapper(
|
||||
treeView, Core::TreeViewFind::FetchMoreWhileSearching));
|
||||
verticalLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(
|
||||
treeView, Core::ItemViewFind::FetchMoreWhileSearching));
|
||||
|
||||
// tree model
|
||||
treeModel = new TreeItemModel(this);
|
||||
|
||||
@@ -222,6 +222,8 @@ QtcPlugin {
|
||||
"ifindfilter.h",
|
||||
"ifindsupport.cpp",
|
||||
"ifindsupport.h",
|
||||
"itemviewfind.cpp",
|
||||
"itemviewfind.h",
|
||||
"searchresultcolor.h",
|
||||
"searchresulttreeitemdelegate.cpp",
|
||||
"searchresulttreeitemdelegate.h",
|
||||
@@ -237,8 +239,6 @@ QtcPlugin {
|
||||
"searchresultwindow.cpp",
|
||||
"searchresultwindow.h",
|
||||
"textfindconstants.h",
|
||||
"treeviewfind.cpp",
|
||||
"treeviewfind.h",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ HEADERS += \
|
||||
$$PWD/searchresulttreeview.h \
|
||||
$$PWD/searchresultwindow.h \
|
||||
$$PWD/searchresultwidget.h \
|
||||
$$PWD/treeviewfind.h
|
||||
$$PWD/itemviewfind.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/findtoolwindow.cpp \
|
||||
@@ -31,7 +31,7 @@ SOURCES += \
|
||||
$$PWD/ifindfilter.cpp \
|
||||
$$PWD/ifindsupport.cpp \
|
||||
$$PWD/searchresultwidget.cpp \
|
||||
$$PWD/treeviewfind.cpp
|
||||
$$PWD/itemviewfind.cpp
|
||||
|
||||
FORMS += \
|
||||
$$PWD/findwidget.ui \
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "treeviewfind.h"
|
||||
#include "itemviewfind.h"
|
||||
|
||||
#include <aggregation/aggregate.h>
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
@@ -42,7 +42,7 @@ namespace Core {
|
||||
class ItemModelFindPrivate
|
||||
{
|
||||
public:
|
||||
explicit ItemModelFindPrivate(QTreeView *view, int role, TreeViewFind::FetchOption option)
|
||||
explicit ItemModelFindPrivate(QAbstractItemView *view, int role, ItemViewFind::FetchOption option)
|
||||
: m_view(view),
|
||||
m_incrementalWrappedState(false),
|
||||
m_role(role),
|
||||
@@ -50,58 +50,58 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
QTreeView *m_view;
|
||||
QAbstractItemView *m_view;
|
||||
QModelIndex m_incrementalFindStart;
|
||||
bool m_incrementalWrappedState;
|
||||
int m_role;
|
||||
TreeViewFind::FetchOption m_option;
|
||||
ItemViewFind::FetchOption m_option;
|
||||
};
|
||||
|
||||
TreeViewFind::TreeViewFind(QTreeView *view, int role, FetchOption option)
|
||||
ItemViewFind::ItemViewFind(QAbstractItemView *view, int role, FetchOption option)
|
||||
: d(new ItemModelFindPrivate(view, role, option))
|
||||
{
|
||||
}
|
||||
|
||||
TreeViewFind::~TreeViewFind()
|
||||
ItemViewFind::~ItemViewFind()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool TreeViewFind::supportsReplace() const
|
||||
bool ItemViewFind::supportsReplace() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FindFlags TreeViewFind::supportedFindFlags() const
|
||||
FindFlags ItemViewFind::supportedFindFlags() const
|
||||
{
|
||||
return FindBackward | FindCaseSensitively | FindRegularExpression | FindWholeWords;
|
||||
}
|
||||
|
||||
void TreeViewFind::resetIncrementalSearch()
|
||||
void ItemViewFind::resetIncrementalSearch()
|
||||
{
|
||||
d->m_incrementalFindStart = QModelIndex();
|
||||
d->m_incrementalWrappedState = false;
|
||||
}
|
||||
|
||||
void TreeViewFind::clearHighlights()
|
||||
void ItemViewFind::clearHighlights()
|
||||
{
|
||||
}
|
||||
|
||||
QString TreeViewFind::currentFindString() const
|
||||
QString ItemViewFind::currentFindString() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString TreeViewFind::completedFindString() const
|
||||
QString ItemViewFind::completedFindString() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
void TreeViewFind::highlightAll(const QString &/*txt*/, FindFlags /*findFlags*/)
|
||||
void ItemViewFind::highlightAll(const QString &/*txt*/, FindFlags /*findFlags*/)
|
||||
{
|
||||
}
|
||||
|
||||
IFindSupport::Result TreeViewFind::findIncremental(const QString &txt, FindFlags findFlags)
|
||||
IFindSupport::Result ItemViewFind::findIncremental(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
if (!d->m_incrementalFindStart.isValid()) {
|
||||
d->m_incrementalFindStart = d->m_view->currentIndex();
|
||||
@@ -118,7 +118,7 @@ IFindSupport::Result TreeViewFind::findIncremental(const QString &txt, FindFlags
|
||||
return result;
|
||||
}
|
||||
|
||||
IFindSupport::Result TreeViewFind::findStep(const QString &txt, FindFlags findFlags)
|
||||
IFindSupport::Result ItemViewFind::findStep(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
bool wrapped = false;
|
||||
IFindSupport::Result result = find(txt, findFlags, false/*startFromNext*/,
|
||||
@@ -132,7 +132,7 @@ IFindSupport::Result TreeViewFind::findStep(const QString &txt, FindFlags findFl
|
||||
return result;
|
||||
}
|
||||
|
||||
QWidget *TreeViewFind::createSearchableWrapper(QTreeView *treeView, FetchOption option)
|
||||
QWidget *ItemViewFind::createSearchableWrapper(QAbstractItemView *treeView, FetchOption option)
|
||||
{
|
||||
QWidget *widget = new QWidget;
|
||||
QVBoxLayout *vbox = new QVBoxLayout(widget);
|
||||
@@ -143,12 +143,12 @@ QWidget *TreeViewFind::createSearchableWrapper(QTreeView *treeView, FetchOption
|
||||
|
||||
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
|
||||
agg->add(treeView);
|
||||
agg->add(new TreeViewFind(treeView, Qt::DisplayRole, option));
|
||||
agg->add(new ItemViewFind(treeView, Qt::DisplayRole, option));
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
IFindSupport::Result TreeViewFind::find(const QString &searchTxt,
|
||||
IFindSupport::Result ItemViewFind::find(const QString &searchTxt,
|
||||
FindFlags findFlags,
|
||||
bool startFromCurrentIndex,
|
||||
bool *wrapped)
|
||||
@@ -214,7 +214,8 @@ IFindSupport::Result TreeViewFind::find(const QString &searchTxt,
|
||||
d->m_view->setCurrentIndex(resultIndex);
|
||||
d->m_view->scrollTo(resultIndex);
|
||||
if (resultIndex.parent().isValid())
|
||||
d->m_view->expand(resultIndex.parent());
|
||||
if (QTreeView *treeView = qobject_cast<QTreeView *>(d->m_view))
|
||||
treeView->expand(resultIndex.parent());
|
||||
if (wrapped)
|
||||
*wrapped = anyWrapped;
|
||||
return IFindSupport::Found;
|
||||
@@ -222,7 +223,7 @@ IFindSupport::Result TreeViewFind::find(const QString &searchTxt,
|
||||
return IFindSupport::NotFound;
|
||||
}
|
||||
|
||||
QModelIndex TreeViewFind::nextIndex(const QModelIndex &idx, bool *wrapped) const
|
||||
QModelIndex ItemViewFind::nextIndex(const QModelIndex &idx, bool *wrapped) const
|
||||
{
|
||||
if (wrapped)
|
||||
*wrapped = false;
|
||||
@@ -269,7 +270,7 @@ QModelIndex TreeViewFind::nextIndex(const QModelIndex &idx, bool *wrapped) const
|
||||
return nextIndex;
|
||||
}
|
||||
|
||||
QModelIndex TreeViewFind::prevIndex(const QModelIndex &idx, bool *wrapped) const
|
||||
QModelIndex ItemViewFind::prevIndex(const QModelIndex &idx, bool *wrapped) const
|
||||
{
|
||||
if (wrapped)
|
||||
*wrapped = false;
|
||||
@@ -306,7 +307,7 @@ QModelIndex TreeViewFind::prevIndex(const QModelIndex &idx, bool *wrapped) const
|
||||
return current;
|
||||
}
|
||||
|
||||
QModelIndex TreeViewFind::followingIndex(const QModelIndex &idx, bool backward, bool *wrapped)
|
||||
QModelIndex ItemViewFind::followingIndex(const QModelIndex &idx, bool backward, bool *wrapped)
|
||||
{
|
||||
if (backward)
|
||||
return prevIndex(idx, wrapped);
|
||||
@@ -27,20 +27,20 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef TREEVIEWFIND_H
|
||||
#define TREEVIEWFIND_H
|
||||
#ifndef ITEMVIEWFIND_H
|
||||
#define ITEMVIEWFIND_H
|
||||
|
||||
#include "ifindsupport.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTreeView;
|
||||
class QAbstractItemView;
|
||||
class QModelIndex;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
class ItemModelFindPrivate;
|
||||
|
||||
class CORE_EXPORT TreeViewFind : public IFindSupport
|
||||
class CORE_EXPORT ItemViewFind : public IFindSupport
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -49,9 +49,9 @@ public:
|
||||
FetchMoreWhileSearching
|
||||
};
|
||||
|
||||
explicit TreeViewFind(QTreeView *view, int role = Qt::DisplayRole,
|
||||
explicit ItemViewFind(QAbstractItemView *view, int role = Qt::DisplayRole,
|
||||
FetchOption option = DoNotFetchMoreWhileSearching);
|
||||
virtual ~TreeViewFind();
|
||||
virtual ~ItemViewFind();
|
||||
|
||||
bool supportsReplace() const;
|
||||
FindFlags supportedFindFlags() const;
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
Result findIncremental(const QString &txt, FindFlags findFlags);
|
||||
Result findStep(const QString &txt, FindFlags findFlags);
|
||||
|
||||
static QWidget *createSearchableWrapper(QTreeView *treeView,
|
||||
static QWidget *createSearchableWrapper(QAbstractItemView *treeView,
|
||||
FetchOption option = DoNotFetchMoreWhileSearching);
|
||||
|
||||
private:
|
||||
@@ -81,4 +81,4 @@ private:
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // TREEVIEWFIND_H
|
||||
#endif // ITEMVIEWFIND_H
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "searchresulttreeitemroles.h"
|
||||
|
||||
#include "findplugin.h"
|
||||
#include "treeviewfind.h"
|
||||
#include "itemviewfind.h"
|
||||
|
||||
#include <aggregation/aggregate.h>
|
||||
#include <coreplugin/coreplugin.h>
|
||||
@@ -123,7 +123,7 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
|
||||
m_searchResultTreeView->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
Aggregation::Aggregate * agg = new Aggregation::Aggregate;
|
||||
agg->add(m_searchResultTreeView);
|
||||
agg->add(new TreeViewFind(m_searchResultTreeView,
|
||||
agg->add(new ItemViewFind(m_searchResultTreeView,
|
||||
ItemDataRoles::ResultLineRole));
|
||||
layout->addWidget(m_searchResultTreeView);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "cppincludehierarchytreeview.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/find/treeviewfind.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <cplusplus/CppDocument.h>
|
||||
|
||||
#include <utils/annotateditemdelegate.h>
|
||||
@@ -115,8 +115,8 @@ CppIncludeHierarchyWidget::CppIncludeHierarchyWidget() :
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(m_inspectedFile);
|
||||
layout->addWidget(Core::TreeViewFind::createSearchableWrapper(
|
||||
m_treeView, Core::TreeViewFind::FetchMoreWhileSearching));
|
||||
layout->addWidget(Core::ItemViewFind::createSearchableWrapper(
|
||||
m_treeView, Core::ItemViewFind::FetchMoreWhileSearching));
|
||||
layout->addWidget(m_includeHierarchyInfoLabel);
|
||||
setLayout(layout);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include <cplusplus/OverviewModel.h>
|
||||
|
||||
#include <coreplugin/find/treeviewfind.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDebug>
|
||||
@@ -102,7 +102,7 @@ CppOutlineWidget::CppOutlineWidget(CppEditorWidget *editor) :
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(Core::TreeViewFind::createSearchableWrapper(m_treeView));
|
||||
layout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_treeView));
|
||||
setLayout(layout);
|
||||
|
||||
m_treeView->setModel(m_proxyModel);
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "cppelementevaluator.h"
|
||||
#include "cppeditorplugin.h"
|
||||
|
||||
#include <coreplugin/find/treeviewfind.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/navigationtreeview.h>
|
||||
#include <utils/annotateditemdelegate.h>
|
||||
@@ -151,7 +151,7 @@ CppTypeHierarchyWidget::CppTypeHierarchyWidget() :
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(m_inspectedClass);
|
||||
layout->addWidget(Core::TreeViewFind::createSearchableWrapper(m_treeView));
|
||||
layout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_treeView));
|
||||
m_hierarchyWidget->setLayout(layout);
|
||||
|
||||
m_stackLayout = new QStackedLayout;
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/find/treeviewfind.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <coreplugin/imode.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -538,7 +538,7 @@ static QWidget *addSearch(BaseTreeView *treeView, const QString &title,
|
||||
QObject::connect(act, SIGNAL(toggled(bool)),
|
||||
treeView, SLOT(setAlternatingRowColorsHelper(bool)));
|
||||
|
||||
QWidget *widget = TreeViewFind::createSearchableWrapper(treeView);
|
||||
QWidget *widget = ItemViewFind::createSearchableWrapper(treeView);
|
||||
widget->setObjectName(QLatin1String(objectName));
|
||||
widget->setWindowTitle(title);
|
||||
return widget;
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/find/treeviewfind.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
|
||||
#include <utils/navigationtreeview.h>
|
||||
#include <utils/algorithm.h>
|
||||
@@ -135,8 +135,8 @@ ProjectTreeWidget::ProjectTreeWidget(QWidget *parent)
|
||||
initView();
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
layout->addWidget(Core::TreeViewFind::createSearchableWrapper(
|
||||
m_view, TreeViewFind::FetchMoreWhileSearching));
|
||||
layout->addWidget(Core::ItemViewFind::createSearchableWrapper(
|
||||
m_view, ItemViewFind::FetchMoreWhileSearching));
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
setLayout(layout);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "qmljseditoreditable.h"
|
||||
#include "qmljsoutlinetreeview.h"
|
||||
|
||||
#include <coreplugin/find/treeviewfind.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
@@ -110,7 +110,7 @@ QmlJSOutlineWidget::QmlJSOutlineWidget(QWidget *parent) :
|
||||
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(Core::TreeViewFind::createSearchableWrapper(m_treeView));
|
||||
layout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_treeView));
|
||||
|
||||
m_showBindingsAction = new QAction(this);
|
||||
m_showBindingsAction->setText(tr("Show All Bindings"));
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
#include <utils/savedaction.h>
|
||||
#include <aggregation/aggregate.h>
|
||||
#include <coreplugin/find/treeviewfind.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QLabel>
|
||||
@@ -96,7 +96,7 @@ QmlConsolePane::QmlConsolePane(QObject *parent)
|
||||
|
||||
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate();
|
||||
aggregate->add(m_consoleView);
|
||||
aggregate->add(new Core::TreeViewFind(m_consoleView));
|
||||
aggregate->add(new Core::ItemViewFind(m_consoleView));
|
||||
|
||||
vbox->addWidget(m_consoleView);
|
||||
vbox->addWidget(new Core::FindToolBarPlaceHolder(m_consoleWidget));
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <coreplugin/actionmanager/commandbutton.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/find/treeviewfind.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <utils/reloadpromptutils.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
@@ -92,7 +92,7 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context,
|
||||
|
||||
Aggregation::Aggregate * agg = new Aggregation::Aggregate;
|
||||
agg->add(m_resourceEditor->treeView());
|
||||
agg->add(new Core::TreeViewFind(m_resourceEditor->treeView()));
|
||||
agg->add(new Core::ItemViewFind(m_resourceEditor->treeView()));
|
||||
|
||||
m_resourceEditor->setResourceDragEnabled(true);
|
||||
m_contextMenu->addAction(tr("Open File"), this, SLOT(openCurrentFile()));
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <coreplugin/find/treeviewfind.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
@@ -69,7 +69,7 @@ void tst_treeviewfind::wrapping()
|
||||
tree->addTopLevelItems(toplevelitems);
|
||||
|
||||
// set up
|
||||
Core::TreeViewFind *findSupport = new Core::TreeViewFind(tree);
|
||||
Core::ItemViewFind *findSupport = new Core::ItemViewFind(tree);
|
||||
tree->setCurrentItem(toplevelitems.at(2)->child(0));
|
||||
QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("FOO2"));
|
||||
|
||||
@@ -114,7 +114,7 @@ void tst_treeviewfind::columns()
|
||||
tree->addTopLevelItems(toplevelitems);
|
||||
|
||||
// set up
|
||||
Core::TreeViewFind *findSupport = new Core::TreeViewFind(tree);
|
||||
Core::ItemViewFind *findSupport = new Core::ItemViewFind(tree);
|
||||
tree->setCurrentItem(toplevelitems.at(0));
|
||||
QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("HEADER1"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user