C

Qt Quick Ultralite image_cache Example

// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
#pragma once
#include <qul/private/models.h>

struct ImageModelData
{
    ImageModelData()
        : imagePath(NULL){};
    ImageModelData(const char *path)
        : imagePath(path){};

    const char *imagePath;

    bool operator==(const ImageModelData &) const
    {
        // We know that there are no duplicates.
        return false;
    }
};

struct ImageModel : Qul::ListModel<ImageModelData>
{
    ImageModel()
        : swapImageSet(false){};

    bool swapImageSet;

    int count() const QUL_DECL_OVERRIDE;
    ImageModelData data(int idx) const QUL_DECL_OVERRIDE;

    void swapImages();
};