Exemplo n.º 1
0
bool
QResourceInfo::loadResource(const QString &path)
{
    ensureInitialized();
    const ResourceList *list = resourceList();
    for(int i = 0; i < list->size(); ++i) {
        QResource res = list->at(i);
        if(res.exists(path)) {
            if(related.isEmpty())
                container = res.isContainer(path);
            else if(res.isContainer(path) != container)
                qWarning("Resource [%s] has both data and children!", file.toLatin1().constData());
            related.append(res);
        }
    }
    return !related.isEmpty();
}
Exemplo n.º 2
0
QByteArray QResourceInfo::data() const
{
    if(container || related.isEmpty())
        return QByteArray();

    if(!hasData) {
        hasData = true;
        QString path = searchFile;
        if(path.startsWith(QLatin1Char(':')))
            path = path.mid(1);
        mData = related.at(0).data(path);
    }
    return mData;
}
Exemplo n.º 3
0
QStringList QResourceInfo::children() const
{
    if(!container || related.isEmpty())
        return QStringList();

    if(!hasChildren) {
        hasChildren = true;
        QString path = searchFile;
        if(path.startsWith(QLatin1Char(':')))
            path = path.mid(1);
        QSet<QString> kids;
        for(int i = 0; i < related.size(); ++i) {
            QStringList related_children = related.at(i).children(path);
            for(int kid = 0; kid < related_children.size(); ++kid) {
                QString k = related_children.at(kid);
                if(!kids.contains(k)) {
                    mChildren += k;
                    kids.insert(k);
                }
            }
        }
    }
    return mChildren;
}
Exemplo n.º 4
0
 bool exists() const { ensureInitialized(); return !related.isEmpty(); }