2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-02-18 10:36:52 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-07-08 11:26:33 +02:00
|
|
|
|
|
|
|
|
#include "cppeditor.h"
|
|
|
|
|
|
|
|
|
|
#include <texteditor/ioutlinewidget.h>
|
|
|
|
|
|
2013-03-27 18:54:03 +01:00
|
|
|
#include <utils/navigationtreeview.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSortFilterProxyModel>
|
2010-07-08 11:26:33 +02:00
|
|
|
|
2014-05-23 13:55:03 -04:00
|
|
|
namespace CPlusPlus { class OverviewModel; }
|
|
|
|
|
|
2010-07-08 11:26:33 +02:00
|
|
|
namespace CppEditor {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-07-16 11:18:30 +02:00
|
|
|
class CppOutlineTreeView : public Utils::NavigationTreeView
|
2010-07-08 11:26:33 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
CppOutlineTreeView(QWidget *parent);
|
2010-12-20 09:15:49 +01:00
|
|
|
|
|
|
|
|
void contextMenuEvent(QContextMenuEvent *event);
|
2010-07-08 11:26:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppOutlineFilterModel : public QSortFilterProxyModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2010-07-08 17:03:38 +02:00
|
|
|
CppOutlineFilterModel(CPlusPlus::OverviewModel *sourceModel, QObject *parent);
|
2010-07-08 11:26:33 +02:00
|
|
|
// QSortFilterProxyModel
|
|
|
|
|
bool filterAcceptsRow(int sourceRow,
|
|
|
|
|
const QModelIndex &sourceParent) const;
|
2014-09-29 14:41:42 +02:00
|
|
|
Qt::DropActions supportedDragActions() const;
|
2010-07-08 17:03:38 +02:00
|
|
|
private:
|
|
|
|
|
CPlusPlus::OverviewModel *m_sourceModel;
|
2010-07-08 11:26:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppOutlineWidget : public TextEditor::IOutlineWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2014-07-30 16:30:31 +02:00
|
|
|
CppOutlineWidget(CppEditorWidget *editor);
|
2010-07-08 11:26:33 +02:00
|
|
|
|
|
|
|
|
// IOutlineWidget
|
2010-07-14 16:46:54 +02:00
|
|
|
virtual QList<QAction*> filterMenuActions() const;
|
2010-07-08 11:26:33 +02:00
|
|
|
virtual void setCursorSynchronization(bool syncWithCursor);
|
|
|
|
|
|
2016-05-28 23:47:48 +03:00
|
|
|
private:
|
2010-07-08 15:47:59 +02:00
|
|
|
void modelUpdated();
|
2010-07-08 16:00:41 +02:00
|
|
|
void updateSelectionInTree(const QModelIndex &index);
|
2010-12-20 09:44:54 +01:00
|
|
|
void updateTextCursor(const QModelIndex &index);
|
2014-06-25 17:06:55 -04:00
|
|
|
void onItemActivated(const QModelIndex &index);
|
2010-07-08 11:26:33 +02:00
|
|
|
bool syncCursor();
|
|
|
|
|
|
|
|
|
|
private:
|
2014-07-30 16:30:31 +02:00
|
|
|
CppEditorWidget *m_editor;
|
2010-07-08 11:26:33 +02:00
|
|
|
CppOutlineTreeView *m_treeView;
|
|
|
|
|
CPlusPlus::OverviewModel *m_model;
|
|
|
|
|
CppOutlineFilterModel *m_proxyModel;
|
|
|
|
|
|
|
|
|
|
bool m_enableCursorSync;
|
|
|
|
|
bool m_blockCursorSync;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CppOutlineWidgetFactory : public TextEditor::IOutlineWidgetFactory
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
bool supportsEditor(Core::IEditor *editor) const;
|
|
|
|
|
TextEditor::IOutlineWidget *createWidget(Core::IEditor *editor);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CppEditor
|