// Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "cppoutline.h" #include "cppeditordocument.h" #include "cppeditoroutline.h" #include "cppeditortr.h" #include "cppeditorwidget.h" #include "cppmodelmanager.h" #include "cppoutlinemodel.h" #include #include #include #include #include #include #include #include #include #include #include using namespace TextEditor; namespace CppEditor::Internal { class CppOutlineTreeView final : public Utils::NavigationTreeView { public: CppOutlineTreeView(QWidget *parent) : Utils::NavigationTreeView(parent) { setExpandsOnDoubleClick(false); setDragEnabled(true); setDragDropMode(QAbstractItemView::DragOnly); } void contextMenuEvent(QContextMenuEvent *event) final { if (!event) return; QMenu contextMenu; QAction *action = contextMenu.addAction(Tr::tr("Expand All")); connect(action, &QAction::triggered, this, &QTreeView::expandAll); action = contextMenu.addAction(Tr::tr("Collapse All")); connect(action, &QAction::triggered, this, &QTreeView::collapseAll); contextMenu.exec(event->globalPos()); event->accept(); } }; class CppOutlineFilterModel : public QSortFilterProxyModel { public: CppOutlineFilterModel(OutlineModel &sourceModel, QObject *parent) : QSortFilterProxyModel(parent) , m_sourceModel(sourceModel) {} bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const final { // ignore artificial "