1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "contentlibrarytexturescategory.h"
#include "contentlibrarytexture.h"
#include <utils/algorithm.h>
#include <QFileInfo>
namespace QmlDesigner {
ContentLibraryTexturesCategory::ContentLibraryTexturesCategory(QObject *parent, const QString &name)
: QObject(parent), m_name(name) {}
void ContentLibraryTexturesCategory::addTexture(const QFileInfo &texIcon, const QString &downloadPath,
const QString &key, const QString &webTextureUrl,
const QString &iconUrl, const QString &suffix,
const QSize &dimensions, const qint64 sizeInBytes,
bool hasUpdate, bool isNew)
{
m_categoryTextures.append(new ContentLibraryTexture(
this, texIcon, downloadPath, suffix, dimensions, sizeInBytes,
key, webTextureUrl, iconUrl, hasUpdate, isNew));
}
bool ContentLibraryTexturesCategory::filter(const QString &searchText)
{
bool visible = false;
for (ContentLibraryTexture *tex : std::as_const(m_categoryTextures))
visible |= tex->filter(searchText);
if (visible != m_visible) {
m_visible = visible;
emit categoryVisibleChanged();
return true;
}
return false;
}
QString ContentLibraryTexturesCategory::name() const
{
return m_name;
}
bool ContentLibraryTexturesCategory::visible() const
{
return m_visible;
}
bool ContentLibraryTexturesCategory::expanded() const
{
return m_expanded;
}
QList<ContentLibraryTexture *> ContentLibraryTexturesCategory::categoryTextures() const
{
return m_categoryTextures;
}
void ContentLibraryTexturesCategory::markTextureHasNoUpdate(const QString &textureKey)
{
auto *texture = Utils::findOrDefault(m_categoryTextures, [&textureKey](ContentLibraryTexture *t) {
return t->textureKey() == textureKey;
});
if (texture)
texture->setHasUpdate(false);
}
} // namespace QmlDesigner
|