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);
|
|
|
|
|
|
|
|
|
|
//QStandardItem
|
|
|
|
|
QVariant data(int role = Qt::UserRole + 1) const;
|
2010-07-19 14:28:53 +02:00
|
|
|
int type() const;
|
|
|
|
|
|
|
|
|
|
QmlJS::AST::SourceLocation sourceLocation() const;
|
|
|
|
|
void setSourceLocation(const QmlJS::AST::SourceLocation &location);
|
|
|
|
|
|
|
|
|
|
QmlJS::AST::Node *node() const;
|
|
|
|
|
void setNode(QmlJS::AST::Node *node);
|
|
|
|
|
|
|
|
|
|
QmlJS::AST::UiQualifiedId *idNode() const;
|
|
|
|
|
void setIdNode(QmlJS::AST::UiQualifiedId *idNode);
|
2010-07-19 11:39:41 +02:00
|
|
|
|
|
|
|
|
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-19 14:28:53 +02:00
|
|
|
QmlJS::AST::Node *m_node;
|
|
|
|
|
QmlJS::AST::UiQualifiedId *m_idNode;
|
2010-07-16 11:03:42 +02:00
|
|
|
};
|
|
|
|
|
|
2010-07-19 14:28:53 +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,
|
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-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-07-19 14:02:17 +02:00
|
|
|
QmlJS::AST::Node *nodeForIndex(const QModelIndex &index);
|
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();
|
|
|
|
|
|
|
|
|
|
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-07-16 11:03:42 +02:00
|
|
|
QModelIndex enterNode(const QmlOutlineItem &prototype);
|
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);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
#endif // QMLOUTLINEMODEL_H
|