2010-07-12 09:44:42 +02:00
|
|
|
#ifndef QMLOUTLINEMODEL_H
|
|
|
|
|
#define QMLOUTLINEMODEL_H
|
|
|
|
|
|
2010-07-19 11:39:41 +02:00
|
|
|
#include "qmljseditor.h"
|
2010-07-12 09:44:42 +02:00
|
|
|
#include <qmljs/qmljsdocument.h>
|
|
|
|
|
#include <qmljs/qmljsicons.h>
|
2010-07-19 11:39:41 +02:00
|
|
|
#include <qmljs/qmljslookupcontext.h>
|
2010-07-12 09:44:42 +02:00
|
|
|
|
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
|
|
2010-07-19 11:39:41 +02:00
|
|
|
namespace QmlJS {
|
|
|
|
|
namespace Interpreter {
|
|
|
|
|
class Value;
|
|
|
|
|
class Context;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-12 09:44:42 +02:00
|
|
|
namespace QmlJSEditor {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-07-19 11:39:41 +02:00
|
|
|
class QmlOutlineModel;
|
|
|
|
|
|
2010-07-16 11:03:42 +02:00
|
|
|
class QmlOutlineItem : public QStandardItem
|
|
|
|
|
{
|
|
|
|
|
public:
|
2010-07-19 11:39:41 +02:00
|
|
|
QmlOutlineItem(QmlOutlineModel *model);
|
|
|
|
|
|
|
|
|
|
//QStandardItem
|
|
|
|
|
QVariant data(int role = Qt::UserRole + 1) const;
|
|
|
|
|
|
|
|
|
|
QmlOutlineItem ©Values(const QmlOutlineItem &other); // so that we can assign all values at onc
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString prettyPrint(const QmlJS::Interpreter::Value *value, QmlJS::Interpreter::Context *context) const;
|
|
|
|
|
|
|
|
|
|
QmlOutlineModel *m_outlineModel;
|
2010-07-16 11:03:42 +02:00
|
|
|
};
|
|
|
|
|
|
2010-07-12 09:44:42 +02:00
|
|
|
class QmlOutlineModel : public QStandardItemModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2010-07-16 11:03:42 +02:00
|
|
|
|
2010-07-12 09:44:42 +02:00
|
|
|
enum CustomRoles {
|
2010-07-14 16:46:54 +02:00
|
|
|
SourceLocationRole = Qt::UserRole + 1,
|
2010-07-19 11:39:41 +02:00
|
|
|
ItemTypeRole,
|
|
|
|
|
NodePointerRole,
|
|
|
|
|
IdPointerRole
|
2010-07-14 16:46:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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-19 11:39:41 +02:00
|
|
|
void update(const SemanticInfo &semanticInfo);
|
|
|
|
|
|
|
|
|
|
QModelIndex enterObjectDefinition(QmlJS::AST::UiObjectDefinition *objectDefinition);
|
|
|
|
|
void leaveObjectDefiniton();
|
|
|
|
|
|
|
|
|
|
QModelIndex enterScriptBinding(QmlJS::AST::UiScriptBinding *scriptBinding);
|
|
|
|
|
void leaveScriptBinding();
|
2010-07-12 09:44:42 +02:00
|
|
|
|
2010-07-19 11:39:41 +02:00
|
|
|
QModelIndex enterPublicMember(QmlJS::AST::UiPublicMember *publicMember);
|
|
|
|
|
void leavePublicMember();
|
2010-07-12 09:44:42 +02:00
|
|
|
|
2010-07-19 11:39:41 +02:00
|
|
|
QmlJS::AST::Node *nodeForIndex(const QModelIndex &index);
|
2010-07-12 09:44:42 +02:00
|
|
|
|
2010-07-12 14:45:22 +02:00
|
|
|
signals:
|
|
|
|
|
void updated();
|
|
|
|
|
|
2010-07-12 09:44:42 +02:00
|
|
|
private:
|
2010-07-16 11:03:42 +02:00
|
|
|
QModelIndex enterNode(const QmlOutlineItem &prototype);
|
2010-07-12 09:44:42 +02:00
|
|
|
void leaveNode();
|
|
|
|
|
|
|
|
|
|
QStandardItem *parentItem();
|
|
|
|
|
|
2010-07-19 11:39:41 +02:00
|
|
|
static QString asString(QmlJS::AST::UiQualifiedId *id);
|
|
|
|
|
static QmlJS::AST::SourceLocation getLocation(QmlJS::AST::UiObjectMember *objMember);
|
|
|
|
|
QIcon getIcon(QmlJS::AST::UiObjectDefinition *objDef);
|
|
|
|
|
static QString getId(QmlJS::AST::UiObjectDefinition *objDef);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SemanticInfo m_semanticInfo;
|
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;
|
|
|
|
|
|
2010-07-19 11:39:41 +02:00
|
|
|
QmlJS::LookupContext::Ptr m_context;
|
|
|
|
|
QHash<QString, QIcon> m_typeToIcon;
|
|
|
|
|
|
2010-07-13 17:05:47 +02:00
|
|
|
friend class QmlOutlineModelSync;
|
2010-07-19 11:39:41 +02:00
|
|
|
friend class QmlOutlineItem;
|
2010-07-12 09:44:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlJSEditor
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(QmlJS::AST::SourceLocation);
|
2010-07-19 11:39:41 +02:00
|
|
|
Q_DECLARE_METATYPE(QmlJS::AST::Node*);
|
|
|
|
|
Q_DECLARE_METATYPE(QmlJS::AST::UiQualifiedId*);
|
2010-07-12 09:44:42 +02:00
|
|
|
|
|
|
|
|
#endif // QMLOUTLINEMODEL_H
|