Logo Search packages:      
Sourcecode: qapt version File versions  Download package

void QApt::Backend::reloadCache (  ) 

Repopulates the internal package cache, package list, and group list. Mostly used internally, like after an update or a package installation or removal.

Definition at line 124 of file backend.cpp.

References packageCount().

Referenced by init().

{
    Q_D(Backend);

    d->cache->open();

    pkgDepCache *depCache = d->cache->depCache();

    delete d->records;
    d->records = new pkgRecords(*depCache);

    qDeleteAll(d->packages);
    d->packages.clear();
    d->groups.clear();
    d->originMap.clear();
    d->packagesIndex.clear();

    int packageCount = depCache->Head().PackageCount;
    d->packagesIndex.resize(packageCount);

    // Remove check when sid has >= 4.7
    #if QT_VERSION >= 0x040700
    d->packages.reserve(packageCount);
    #endif

    // Populate internal package cache
    int count = 0;
    QSet<Group> groupSet;
    QStringList originList;
    QStringList originLabelList;

    pkgCache::PkgIterator iter;
    for (iter = depCache->PkgBegin(); !iter.end(); ++iter) {
        if (iter->VersionList == 0) {
            continue; // Exclude virtual packages.
        }

        Package *pkg = new Package(this, depCache, d->records, iter);
        d->packagesIndex[iter->ID] = count;
        d->packages.insert(count++, pkg);

        QString group = QString::fromStdString(iter.Section());

        if (!group.isEmpty()) {
            groupSet << group;
        }

        pkgCache::VerIterator Ver = (*depCache)[iter].CandidateVerIter(*depCache);

        if(!Ver.end()) {
            pkgCache::VerFileIterator VF = Ver.FileList();
            d->originMap[VF.File().Origin()] = VF.File().Label();
        }
    }

    if (d->originMap.contains("")) {
        d->originMap.remove("");
    }

    // Populate groups
    foreach (const QString &group, groupSet) {
        d->groups << group;
    }

    d->undoStack.clear();
    d->redoStack.clear();
}


Generated by  Doxygen 1.6.0   Back to index