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-19 14:28:53 +02:00
|
|
|
#include <utils/changeset.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);
|
|
|
|
|
|
2010-08-12 14:37:52 +02:00
|
|
|
// QStandardItem
|
2010-07-19 11:39:41 +02:00
|
|
|
QVariant data(int role = Qt::UserRole + 1) const;
|
2010-07-19 14:28:53 +02:00
|
|
|
int type() const;
|
|
|
|
|
|
2010-07-19 11:39:41 +02:00
|
|
|
private:
|
2010-08-25 11:51:34 +02:00
|
|
|
QString prettyPrint(const QmlJS::Interpreter::Value *value, const QmlJS::Interpreter::Context *context) const;
|
2010-07-19 11:39:41 +02:00
|
|
|
|
|
|
|
|
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-08-25 13:21:38 +02:00
|
|
|
ItemTypeRole = Qt::UserRole + 1,
|
|
|
|
|
ElementTypeRole,
|
2010-08-10 14:33:13 +02:00
|
|
|
AnnotationRole
|
2010-07-14 16:46:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ItemTypes {
|
|
|
|
|
ElementType,
|
2010-08-12 12:47:25 +02:00
|
|
|
ElementBindingType, // might contain elements as childs
|
|
|
|
|
NonElementBindingType // can be filtered out
|
2010-07-12 09:44:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QmlOutlineModel(QObject *parent = 0);
|
|
|
|
|
|
2010-07-19 14:28:53 +02:00
|
|
|
// QStandardItemModel
|
|
|
|
|
QStringList mimeTypes() const;
|
|
|
|
|
QMimeData *mimeData(const QModelIndexList &indexes) const;
|
|
|
|
|
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
|
|
|
|
|
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);
|
2010-08-25 13:21:38 +02:00
|
|
|
|
|
|
|
|
QmlJS::AST::Node *nodeForIndex(const QModelIndex &index) const;
|
|
|
|
|
QmlJS::AST::SourceLocation sourceLocation(const QModelIndex &index) const;
|
|
|
|
|
QmlJS::AST::UiQualifiedId *idNode(const QModelIndex &index) const;
|
|
|
|
|
QIcon icon(const QModelIndex &index) const;
|
2010-07-19 11:39:41 +02:00
|
|
|
|
2010-07-19 14:02:17 +02:00
|
|
|
signals:
|
|
|
|
|
void updated();
|
|
|
|
|
|
|
|
|
|
private:
|
2010-07-19 11:39:41 +02:00
|
|
|
QModelIndex enterObjectDefinition(QmlJS::AST::UiObjectDefinition *objectDefinition);
|
|
|
|
|
void leaveObjectDefiniton();
|
|
|
|
|
|
2010-08-10 16:33:23 +02:00
|
|
|
QModelIndex enterObjectBinding(QmlJS::AST::UiObjectBinding *objectBinding);
|
|
|
|
|
void leaveObjectBinding();
|
|
|
|
|
|
|
|
|
|
QModelIndex enterArrayBinding(QmlJS::AST::UiArrayBinding *arrayBinding);
|
|
|
|
|
void leaveArrayBinding();
|
|
|
|
|
|
2010-07-19 11:39:41 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
private:
|
2010-08-25 13:21:38 +02:00
|
|
|
QmlOutlineItem *enterNode(QMap<int, QVariant> data);
|
2010-07-12 09:44:42 +02:00
|
|
|
void leaveNode();
|
|
|
|
|
|
2010-07-19 14:28:53 +02:00
|
|
|
void reparentNodes(QmlOutlineItem *targetItem, int targetRow, QList<QmlOutlineItem*> itemsToMove);
|
|
|
|
|
void moveObjectMember(QmlJS::AST::UiObjectMember *toMove, QmlJS::AST::UiObjectMember *newParent,
|
|
|
|
|
bool insertionOrderSpecified, QmlJS::AST::UiObjectMember *insertAfter,
|
|
|
|
|
Utils::ChangeSet *changeSet, Utils::ChangeSet::Range *addedRange);
|
|
|
|
|
|
2010-07-12 09:44:42 +02:00
|
|
|
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);
|
2010-08-10 16:33:23 +02:00
|
|
|
QIcon getIcon(QmlJS::AST::UiQualifiedId *objDef);
|
2010-08-10 15:11:14 +02:00
|
|
|
|
2010-08-12 15:10:19 +02:00
|
|
|
QString getAnnotation(QmlJS::AST::UiObjectInitializer *objInitializer);
|
|
|
|
|
QString getAnnotation(QmlJS::AST::Statement *statement);
|
|
|
|
|
QString getAnnotation(QmlJS::AST::ExpressionNode *expression);
|
|
|
|
|
QHash<QString,QString> getScriptBindings(QmlJS::AST::UiObjectInitializer *objInitializer);
|
2010-07-19 11:39:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
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-08-25 13:21:38 +02:00
|
|
|
QHash<QmlOutlineItem*,QIcon> m_itemToIcon;
|
|
|
|
|
QHash<QmlOutlineItem*,QmlJS::AST::Node*> m_itemToNode;
|
|
|
|
|
QHash<QmlOutlineItem*,QmlJS::AST::UiQualifiedId*> m_itemToIdNode;
|
|
|
|
|
|
2010-07-19 11:39:41 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
#endif // QMLOUTLINEMODEL_H
|