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:
@@ -445,7 +445,7 @@ Item {
|
|||||||
hideHeader: dirDepth === 0
|
hideHeader: dirDepth === 0
|
||||||
showLeftBorder: dirDepth > 0
|
showLeftBorder: dirDepth > 0
|
||||||
expanded: dirExpanded
|
expanded: dirExpanded
|
||||||
visible: !assetsModel.isEmpty && dirVisible
|
visible: dirVisible
|
||||||
expandOnClick: false
|
expandOnClick: false
|
||||||
useDefaulContextMenu: false
|
useDefaulContextMenu: false
|
||||||
|
|
||||||
|
|||||||
@@ -341,8 +341,14 @@ void AssetsLibraryModel::setRootPath(const QString &path)
|
|||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_assetsDir = new AssetsLibraryDir(path, 0, true, this);
|
m_assetsDir = new AssetsLibraryDir(path, 0, true, this);
|
||||||
bool noAssets = parseDirRecursive(m_assetsDir, 1);
|
bool isEmpty = parseDirRecursive(m_assetsDir, 1);
|
||||||
setIsEmpty(noAssets);
|
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();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ public:
|
|||||||
void setRootPath(const QString &path);
|
void setRootPath(const QString &path);
|
||||||
void setSearchText(const QString &searchText);
|
void setSearchText(const QString &searchText);
|
||||||
|
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
static const QStringList &supportedImageSuffixes();
|
static const QStringList &supportedImageSuffixes();
|
||||||
static const QStringList &supportedFragmentShaderSuffixes();
|
static const QStringList &supportedFragmentShaderSuffixes();
|
||||||
static const QStringList &supportedShaderSuffixes();
|
static const QStringList &supportedShaderSuffixes();
|
||||||
@@ -93,7 +95,6 @@ signals:
|
|||||||
private:
|
private:
|
||||||
const QSet<QString> &supportedSuffixes() const;
|
const QSet<QString> &supportedSuffixes() const;
|
||||||
|
|
||||||
bool isEmpty() const;
|
|
||||||
void setIsEmpty(bool empty);
|
void setIsEmpty(bool empty);
|
||||||
|
|
||||||
SynchronousImageCache &m_fontImageCache;
|
SynchronousImageCache &m_fontImageCache;
|
||||||
|
|||||||
@@ -201,10 +201,11 @@ QList<QToolButton *> AssetsLibraryWidget::createToolBarWidgets()
|
|||||||
|
|
||||||
void AssetsLibraryWidget::handleSearchfilterChanged(const QString &filterText)
|
void AssetsLibraryWidget::handleSearchfilterChanged(const QString &filterText)
|
||||||
{
|
{
|
||||||
if (filterText != m_filterText) {
|
if (filterText == m_filterText || (m_assetsModel->isEmpty() && filterText.contains(m_filterText)))
|
||||||
|
return;
|
||||||
|
|
||||||
m_filterText = filterText;
|
m_filterText = filterText;
|
||||||
updateSearch();
|
updateSearch();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetsLibraryWidget::handleAddAsset()
|
void AssetsLibraryWidget::handleAddAsset()
|
||||||
|
|||||||
Reference in New Issue
Block a user