forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user