QmlJSOutline: Optimize performance of QmlOutlineModel

Previously we're setting the properties of the items one by one, each
time potentially triggering an update of the view. Actually this
uncovered an error in the Filter, which was only reacting to the first
change and therefore didn't take the item type into account on first
load.

Instead, we now use our own QStandardItem class which can be used to
assign all values at once.
This commit is contained in:
Kai Koehne
2010-07-16 11:03:42 +02:00
parent f0c7ef6270
commit ff5506f3b9
2 changed files with 57 additions and 44 deletions

View File

@@ -9,10 +9,17 @@
namespace QmlJSEditor {
namespace Internal {
class QmlOutlineItem : public QStandardItem
{
public:
QmlOutlineItem &copyValues(const QmlOutlineItem &other); // so that we can assign all values at once
};
class QmlOutlineModel : public QStandardItemModel
{
Q_OBJECT
public:
enum CustomRoles {
SourceLocationRole = Qt::UserRole + 1,
ItemTypeRole = SourceLocationRole + 1
@@ -40,7 +47,7 @@ signals:
void updated();
private:
QStandardItem *enterNode(const QmlJS::AST::SourceLocation &location);
QModelIndex enterNode(const QmlOutlineItem &prototype);
void leaveNode();
QStandardItem *parentItem();