old render cleanup part 1
This commit is contained in:
38 files changed
+166
-1366
No files matched your search
@@ -7,36 +7,6 @@
|
||||
#include <QFileInfo>
|
||||
#include <QQmlEngine>
|
||||
|
||||
// Dispatches load() calls to the right child loader based on the image:// host (scheme name).
|
||||
class CompositeImageLoader : public IImageLoader {
|
||||
public:
|
||||
void add(const QString &host, std::unique_ptr<IImageLoader> loader)
|
||||
{
|
||||
m_loaders.emplace_back(host, std::move(loader));
|
||||
}
|
||||
|
||||
QImage load(const QUrl &url, int maxWidth) const override
|
||||
{
|
||||
const QString host = url.host();
|
||||
for (const auto &[h, loader] : m_loaders) {
|
||||
if (h == host)
|
||||
return loader->load(url, maxWidth);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unique_ptr<IImageLoader> clone() const override
|
||||
{
|
||||
auto c = std::make_unique<CompositeImageLoader>();
|
||||
for (const auto &[host, loader] : m_loaders)
|
||||
c->add(host, loader->clone());
|
||||
return c;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<std::pair<QString, std::unique_ptr<IImageLoader>>> m_loaders;
|
||||
};
|
||||
|
||||
FormatRegistry::FormatRegistry(QVector<FormatSpec> specs)
|
||||
: m_specs(std::move(specs))
|
||||
{
|
||||
@@ -69,24 +39,6 @@ IImageProvider *FormatRegistry::createImageProvider(const QString &filePath) con
|
||||
return new EntryImageProvider(spec->makeSource, spec->scheme);
|
||||
}
|
||||
|
||||
std::unique_ptr<IImageLoader> FormatRegistry::createImageLoader(const QString &filePath) const
|
||||
{
|
||||
const FormatSpec *spec = specFor(filePath);
|
||||
if (!spec || spec->scheme.isEmpty() || !spec->makeSource)
|
||||
return nullptr;
|
||||
|
||||
auto loader = std::make_unique<EntryImageProvider>(spec->makeSource, spec->scheme);
|
||||
loader->setFilePath(filePath);
|
||||
|
||||
if (!spec->loaderIncludesWeb)
|
||||
return loader;
|
||||
|
||||
auto composite = std::make_unique<CompositeImageLoader>();
|
||||
composite->add(spec->scheme, std::move(loader));
|
||||
composite->add(QStringLiteral("web"), std::make_unique<WebImageProvider>());
|
||||
return composite;
|
||||
}
|
||||
|
||||
QStringList FormatRegistry::supportedExtensions() const
|
||||
{
|
||||
QStringList out;
|
||||
|
||||
Reference in new issue
Block a user