forked from qt-creator/qt-creator
QmlOutline: Show sensible tooltips
Show the same tooltips as in the text editor. To accomplish this I refactored the QmlOutlineModel quite a bit ...
This commit is contained in:
@@ -1,18 +1,39 @@
|
||||
#ifndef QMLOUTLINEMODEL_H
|
||||
#define QMLOUTLINEMODEL_H
|
||||
|
||||
#include "qmljseditor.h"
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include <qmljs/qmljsicons.h>
|
||||
#include <qmljs/qmljslookupcontext.h>
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
namespace QmlJS {
|
||||
namespace Interpreter {
|
||||
class Value;
|
||||
class Context;
|
||||
}
|
||||
}
|
||||
|
||||
namespace QmlJSEditor {
|
||||
namespace Internal {
|
||||
|
||||
class QmlOutlineModel;
|
||||
|
||||
class QmlOutlineItem : public QStandardItem
|
||||
{
|
||||
public:
|
||||
QmlOutlineItem ©Values(const QmlOutlineItem &other); // so that we can assign all values at once
|
||||
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;
|
||||
};
|
||||
|
||||
class QmlOutlineModel : public QStandardItemModel
|
||||
@@ -22,7 +43,9 @@ public:
|
||||
|
||||
enum CustomRoles {
|
||||
SourceLocationRole = Qt::UserRole + 1,
|
||||
ItemTypeRole = SourceLocationRole + 1
|
||||
ItemTypeRole,
|
||||
NodePointerRole,
|
||||
IdPointerRole
|
||||
};
|
||||
|
||||
enum ItemTypes {
|
||||
@@ -33,15 +56,18 @@ public:
|
||||
QmlOutlineModel(QObject *parent = 0);
|
||||
|
||||
QmlJS::Document::Ptr document() const;
|
||||
void update(QmlJS::Document::Ptr doc, const QmlJS::Snapshot &snapshot);
|
||||
void update(const SemanticInfo &semanticInfo);
|
||||
|
||||
QModelIndex enterElement(const QString &typeName, const QString &id, const QIcon &icon,
|
||||
const QmlJS::AST::SourceLocation &location);
|
||||
void leaveElement();
|
||||
QModelIndex enterObjectDefinition(QmlJS::AST::UiObjectDefinition *objectDefinition);
|
||||
void leaveObjectDefiniton();
|
||||
|
||||
QModelIndex enterProperty(const QString &name, bool isCustomProperty,
|
||||
const QmlJS::AST::SourceLocation &location);
|
||||
void leaveProperty();
|
||||
QModelIndex enterScriptBinding(QmlJS::AST::UiScriptBinding *scriptBinding);
|
||||
void leaveScriptBinding();
|
||||
|
||||
QModelIndex enterPublicMember(QmlJS::AST::UiPublicMember *publicMember);
|
||||
void leavePublicMember();
|
||||
|
||||
QmlJS::AST::Node *nodeForIndex(const QModelIndex &index);
|
||||
|
||||
signals:
|
||||
void updated();
|
||||
@@ -52,17 +78,29 @@ private:
|
||||
|
||||
QStandardItem *parentItem();
|
||||
|
||||
QmlJS::Document::Ptr m_document;
|
||||
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;
|
||||
QList<int> m_treePos;
|
||||
QStandardItem *m_currentItem;
|
||||
QmlJS::Icons *m_icons;
|
||||
|
||||
QmlJS::LookupContext::Ptr m_context;
|
||||
QHash<QString, QIcon> m_typeToIcon;
|
||||
|
||||
friend class QmlOutlineModelSync;
|
||||
friend class QmlOutlineItem;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlJSEditor
|
||||
|
||||
Q_DECLARE_METATYPE(QmlJS::AST::SourceLocation);
|
||||
Q_DECLARE_METATYPE(QmlJS::AST::Node*);
|
||||
Q_DECLARE_METATYPE(QmlJS::AST::UiQualifiedId*);
|
||||
|
||||
#endif // QMLOUTLINEMODEL_H
|
||||
|
||||
Reference in New Issue
Block a user