qmljsoutline.h 1.88 KB
Newer Older
1
2
3
#ifndef QMLJSOUTLINE_H
#define QMLJSOUTLINE_H

Friedemann Kleint's avatar
Friedemann Kleint committed
4
#include "qmljseditor.h"
5
6
7

#include <texteditor/ioutlinewidget.h>

8
#include <QtGui/QSortFilterProxyModel>
9
10
11
12
13
14
15
16
17
18
19
20

namespace Core {
class IEditor;
}

namespace QmlJS {
class Editor;
};

namespace QmlJSEditor {
namespace Internal {

21
class QmlJSOutlineTreeView;
22

23
24
25
26
27
28
29
30
class QmlJSOutlineFilterModel : public QSortFilterProxyModel
{
    Q_OBJECT
public:
    QmlJSOutlineFilterModel(QObject *parent);
    // QSortFilterProxyModel
    bool filterAcceptsRow(int sourceRow,
                          const QModelIndex &sourceParent) const;
31
    QVariant data(const QModelIndex &index, int role) const;
32
33
34
35
36
37
38

    bool filterBindings() const;
    void setFilterBindings(bool filterBindings);
private:
    bool m_filterBindings;
};

39
40
41
42
43
44
45
46
47
class QmlJSOutlineWidget : public TextEditor::IOutlineWidget
{
    Q_OBJECT
public:
    QmlJSOutlineWidget(QWidget *parent = 0);

    void setEditor(QmlJSTextEditor *editor);

    // IOutlineWidget
48
    virtual QList<QAction*> filterMenuActions() const;
49
    virtual void setCursorSynchronization(bool syncWithCursor);
50
51
    virtual void restoreSettings(int position);
    virtual void saveSettings(int position);
52
53

private slots:
54
55
    void modelUpdated();
    void updateSelectionInTree(const QModelIndex &index);
56
    void updateSelectionInText(const QItemSelection &selection);
57
    void setShowBindings(bool showBindings);
58
59
60
61
62
63

private:
    bool syncCursor();

private:
    QmlJSOutlineTreeView *m_treeView;
64
    QmlJSOutlineFilterModel *m_filterModel;
65
    QmlJSTextEditor *m_editor;
66

67
68
    QAction *m_showBindingsAction;

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
    bool m_enableCursorSync;
    bool m_blockCursorSync;
};

class QmlJSOutlineWidgetFactory : public TextEditor::IOutlineWidgetFactory
{
    Q_OBJECT
public:
    bool supportsEditor(Core::IEditor *editor) const;
    TextEditor::IOutlineWidget *createWidget(Core::IEditor *editor);
};

} // namespace Internal
} // namespace QmlJSEditor

#endif // QMLJSOUTLINE_H