2010-07-12 09:44:42 +02:00
|
|
|
#ifndef QMLOUTLINEMODEL_H
|
|
|
|
|
#define QMLOUTLINEMODEL_H
|
|
|
|
|
|
|
|
|
|
#include <qmljs/qmljsdocument.h>
|
|
|
|
|
#include <qmljs/qmljsicons.h>
|
|
|
|
|
|
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
|
|
|
|
|
|
namespace QmlJSEditor {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class QmlOutlineModel : public QStandardItemModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
enum CustomRoles {
|
2010-07-14 16:46:54 +02:00
|
|
|
SourceLocationRole = Qt::UserRole + 1,
|
|
|
|
|
ItemTypeRole = SourceLocationRole + 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ItemTypes {
|
|
|
|
|
ElementType,
|
|
|
|
|
PropertyType
|
2010-07-12 09:44:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QmlOutlineModel(QObject *parent = 0);
|
|
|
|
|
|
2010-07-13 11:18:42 +02:00
|
|
|
QmlJS::Document::Ptr document() const;
|
2010-07-13 17:05:47 +02:00
|
|
|
void update(QmlJS::Document::Ptr doc, const QmlJS::Snapshot &snapshot);
|
2010-07-12 09:44:42 +02:00
|
|
|
|
2010-07-14 13:32:42 +02:00
|
|
|
QModelIndex enterElement(const QString &typeName, const QString &id, const QIcon &icon,
|
|
|
|
|
const QmlJS::AST::SourceLocation &location);
|
2010-07-12 09:44:42 +02:00
|
|
|
void leaveElement();
|
|
|
|
|
|
2010-07-14 13:32:42 +02:00
|
|
|
QModelIndex enterProperty(const QString &name, bool isCustomProperty,
|
|
|
|
|
const QmlJS::AST::SourceLocation &location);
|
2010-07-12 09:44:42 +02:00
|
|
|
void leaveProperty();
|
|
|
|
|
|
2010-07-12 14:45:22 +02:00
|
|
|
signals:
|
|
|
|
|
void updated();
|
|
|
|
|
|
2010-07-12 09:44:42 +02:00
|
|
|
private:
|
|
|
|
|
QStandardItem *enterNode(const QmlJS::AST::SourceLocation &location);
|
|
|
|
|
void leaveNode();
|
|
|
|
|
|
|
|
|
|
QStandardItem *parentItem();
|
|
|
|
|
|
2010-07-13 11:18:42 +02:00
|
|
|
QmlJS::Document::Ptr m_document;
|
2010-07-12 09:44:42 +02:00
|
|
|
QList<int> m_treePos;
|
|
|
|
|
QStandardItem *m_currentItem;
|
2010-07-13 17:05:47 +02:00
|
|
|
QmlJS::Icons *m_icons;
|
|
|
|
|
|
|
|
|
|
friend class QmlOutlineModelSync;
|
2010-07-12 09:44:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlJSEditor
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(QmlJS::AST::SourceLocation);
|
|
|
|
|
|
|
|
|
|
#endif // QMLOUTLINEMODEL_H
|