aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/coreplugin/find/searchresulttreeview.h
blob: d1ce62daba1e8211a854b8e66a06c70ce4fc8bbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include "searchresultwindow.h"

#include <utils/itemviews.h>

namespace Core {
class SearchResultColor;

namespace Internal {

class SearchResultFilterModel;

class SearchResultTreeView : public Utils::TreeView
{
    Q_OBJECT

public:
    explicit SearchResultTreeView(QWidget *parent = nullptr);

    void setAutoExpandResults(bool expand);
    void setTextEditorFont(const QFont &font, const SearchResultColors &colors);
    void setTabWidth(int tabWidth);

    SearchResultFilterModel *model() const;
    void addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode);
    void setFilter(SearchResultFilter *filter);
    bool hasFilter() const;
    void showFilterWidget(QWidget *parent);

    void keyPressEvent(QKeyEvent *event) override;
    bool event(QEvent *e) override;

signals:
    void jumpToSearchResult(const SearchResultItem &item);
    void filterInvalidated();
    void filterChanged();

public slots:
    void clear();
    void emitJumpToSearchResult(const QModelIndex &index);

protected:
    SearchResultFilterModel *m_model;
    SearchResultFilter *m_filter = nullptr;
    bool m_autoExpandResults;
};

} // namespace Internal
} // namespace Core