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:
		@@ -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,8 +123,8 @@ 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,
 | 
			
		||||
                              ItemDataRoles::ResultLineRole));
 | 
			
		||||
    agg->add(new ItemViewFind(m_searchResultTreeView,
 | 
			
		||||
                                      ItemDataRoles::ResultLineRole));
 | 
			
		||||
    layout->addWidget(m_searchResultTreeView);
 | 
			
		||||
 | 
			
		||||
    m_infoBarDisplay.setTarget(layout, 2);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user