QmlOutline: Cut down update times considerably

Cut down update times of Outline by a magnitude by only emitting
itemChanged signal if absolutely needed. This doesn't include the change
of the icon, because QIcon is missing a comparison operator ...
This commit is contained in:
Kai Koehne
2010-08-25 13:21:38 +02:00
parent 22fe4f584d
commit 6cf563bb25
4 changed files with 148 additions and 171 deletions

View File

@@ -30,38 +30,20 @@ public:
QVariant data(int role = Qt::UserRole + 1) const;
int type() const;
QString annotation() const;
void setAnnotation(const QString &id);
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);
QmlOutlineItem &copyValues(const QmlOutlineItem &other); // so that we can assign all values at onc
private:
QString prettyPrint(const QmlJS::Interpreter::Value *value, const QmlJS::Interpreter::Context *context) const;
QmlOutlineModel *m_outlineModel;
QmlJS::AST::Node *m_node;
QmlJS::AST::UiQualifiedId *m_idNode;
};
class QmlOutlineModel : public QStandardItemModel
{
Q_OBJECT
public:
enum CustomRoles {
SourceLocationRole = Qt::UserRole + 1,
ItemTypeRole,
ItemTypeRole = Qt::UserRole + 1,
ElementTypeRole,
AnnotationRole
};
@@ -80,7 +62,11 @@ public:
QmlJS::Document::Ptr document() const;
void update(const SemanticInfo &semanticInfo);
QmlJS::AST::Node *nodeForIndex(const QModelIndex &index);
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;
signals:
void updated();
@@ -102,7 +88,7 @@ private:
void leavePublicMember();
private:
QModelIndex enterNode(const QmlOutlineItem &prototype);
QmlOutlineItem *enterNode(QMap<int, QVariant> data);
void leaveNode();
void reparentNodes(QmlOutlineItem *targetItem, int targetRow, QList<QmlOutlineItem*> itemsToMove);
@@ -129,6 +115,10 @@ private:
QmlJS::LookupContext::Ptr m_context;
QHash<QString, QIcon> m_typeToIcon;
QHash<QmlOutlineItem*,QIcon> m_itemToIcon;
QHash<QmlOutlineItem*,QmlJS::AST::Node*> m_itemToNode;
QHash<QmlOutlineItem*,QmlJS::AST::UiQualifiedId*> m_itemToIdNode;
friend class QmlOutlineModelSync;
friend class QmlOutlineItem;
@@ -137,6 +127,4 @@ private:
} // namespace Internal
} // namespace QmlJSEditor
Q_DECLARE_METATYPE(QmlJS::AST::SourceLocation);
#endif // QMLOUTLINEMODEL_H