forked from qt-creator/qt-creator
QmlDesigner: Fix assets library warning case
Fixed a warning that appears if the search moves from the "no match found" case to a match case. Also added a small optimization to searching. Change-Id: I9e4759fe00959bcbe1a7018c1bdc6cc43069fca7 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -341,8 +341,14 @@ void AssetsLibraryModel::setRootPath(const QString &path)
|
||||
|
||||
beginResetModel();
|
||||
m_assetsDir = new AssetsLibraryDir(path, 0, true, this);
|
||||
bool noAssets = parseDirRecursive(m_assetsDir, 1);
|
||||
setIsEmpty(noAssets);
|
||||
bool isEmpty = parseDirRecursive(m_assetsDir, 1);
|
||||
setIsEmpty(isEmpty);
|
||||
|
||||
bool noAssets = m_searchText.isEmpty() && isEmpty;
|
||||
// noAssets: the model has no asset files (project has no assets added)
|
||||
// isEmpty: the model has no asset files (assets could exist but are filtered out)
|
||||
|
||||
m_assetsDir->setDirVisible(!noAssets); // if there are no assets, hide all empty asset folders
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ public:
|
||||
void setRootPath(const QString &path);
|
||||
void setSearchText(const QString &searchText);
|
||||
|
||||
bool isEmpty() const;
|
||||
|
||||
static const QStringList &supportedImageSuffixes();
|
||||
static const QStringList &supportedFragmentShaderSuffixes();
|
||||
static const QStringList &supportedShaderSuffixes();
|
||||
@@ -93,7 +95,6 @@ signals:
|
||||
private:
|
||||
const QSet<QString> &supportedSuffixes() const;
|
||||
|
||||
bool isEmpty() const;
|
||||
void setIsEmpty(bool empty);
|
||||
|
||||
SynchronousImageCache &m_fontImageCache;
|
||||
|
||||
@@ -201,10 +201,11 @@ QList<QToolButton *> AssetsLibraryWidget::createToolBarWidgets()
|
||||
|
||||
void AssetsLibraryWidget::handleSearchfilterChanged(const QString &filterText)
|
||||
{
|
||||
if (filterText != m_filterText) {
|
||||
m_filterText = filterText;
|
||||
updateSearch();
|
||||
}
|
||||
if (filterText == m_filterText || (m_assetsModel->isEmpty() && filterText.contains(m_filterText)))
|
||||
return;
|
||||
|
||||
m_filterText = filterText;
|
||||
updateSearch();
|
||||
}
|
||||
|
||||
void AssetsLibraryWidget::handleAddAsset()
|
||||
|
||||
Reference in New Issue
Block a user