QmlDesigner: Improve performance of item library

If there are manu components (e.g. 200) in the same directory,
the model was updated for each component.

This patch compresses the signal and therefore reduced the updates.

Change-Id: I80b38df59952dda7e67e258ecd6e5f29d6a036e6
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
Thomas Hartmann
2016-06-24 15:49:26 +02:00
parent 63e158b4d4
commit 953ec9867f
2 changed files with 14 additions and 2 deletions

View File

@@ -66,6 +66,8 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
m_resourcesView(new ItemLibraryTreeView(this)),
m_filterFlag(QtBasic)
{
m_compressionTimer.setInterval(200);
m_compressionTimer.setSingleShot(true);
ItemLibraryModel::registerQmlTypes();
setWindowTitle(tr("Library", "Title of library view"));
@@ -145,6 +147,8 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
m_qmlSourceUpdateShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F5), this);
connect(m_qmlSourceUpdateShortcut, SIGNAL(activated()), this, SLOT(reloadQmlSource()));
connect(&m_compressionTimer, SIGNAL(timeout()), this, SLOT(updateModel()));
// init the first load of the QML UI elements
reloadQmlSource();
}
@@ -156,11 +160,11 @@ void ItemLibraryWidget::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo)
if (m_itemLibraryInfo)
disconnect(m_itemLibraryInfo.data(), SIGNAL(entriesChanged()),
this, SLOT(updateModel()));
this, SLOT(delayedUpdateModel()));
m_itemLibraryInfo = itemLibraryInfo;
if (itemLibraryInfo)
connect(m_itemLibraryInfo.data(), SIGNAL(entriesChanged()),
this, SLOT(updateModel()));
this, SLOT(delayedUpdateModel()));
updateModel();
}
@@ -209,6 +213,11 @@ void ItemLibraryWidget::setSearchFilter(const QString &searchFilter)
}
}
void ItemLibraryWidget::delayedUpdateModel()
{
m_compressionTimer.start();
}
void ItemLibraryWidget::setModel(Model *model)
{
m_model = model;

View File

@@ -34,6 +34,7 @@
#include <QToolButton>
#include <QFileIconProvider>
#include <QQuickWidget>
#include <QTimer>
QT_BEGIN_NAMESPACE
class QFileSystemModel;
@@ -86,6 +87,7 @@ public:
static QString qmlSourcesPath();
public slots:
void setSearchFilter(const QString &searchFilter);
void delayedUpdateModel();
void updateModel();
void updateSearch();
@@ -107,6 +109,7 @@ private slots:
void reloadQmlSource();
private:
QTimer m_compressionTimer;
QSize m_itemIconSize;
QSize m_resIconSize;
ItemLibraryFileIconProvider m_iconProvider;