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

QStringList QApt::Package::dependencyList ( bool  useCandidateVersion  )  const

Member function that returns a list of the names of all the dependencies of this package. I would like to see if I could figure out how to construct a Package from inside a Package and have this function return a Package::List

Returns:
A list of packages that this package depends on as a QStringList

Definition at line 627 of file package.cpp.

References name(), and version().

{
    QStringList dependsList;
    pkgCache::VerIterator current;

    if(!useCandidateVersion) {
        current = (*d->depCache)[*d->packageIter].InstVerIter(*d->depCache);
    }
    if(useCandidateVersion || current.end()) {
        current = (*d->depCache)[*d->packageIter].CandidateVerIter(*d->depCache);
    }

    // no information found
    if(current.end()) {
        return dependsList;
    }

    for(pkgCache::DepIterator D = current.DependsList(); D.end() != true; ++D) {
        QString type;
        bool isOr = false;
        bool isVirtual = false;
        bool isSatisfied = false;
        QString name;
        QString version;
        QString versionCompare;

        QString finalString;

        // check target and or-depends status
        pkgCache::PkgIterator Trg = D.TargetPkg();
        if ((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or) {
            isOr=true;
        }

        // common information
        type = QString::fromUtf8(D.DepType());
        name = Trg.Name();

        // satisfied
        if (((*d->depCache)[D] & pkgDepCache::DepGInstall) == pkgDepCache::DepGInstall) {
            isSatisfied = true;
        }
        if (Trg->VersionList == 0) {
            isVirtual = true;
        } else {
            version=D.TargetVer();
            versionCompare=D.CompType();
        }

        finalString = "<b>" % type % ":</b> ";
        if (isVirtual) {
            finalString += "<i>" % name % "</i>";
        } else {
            finalString += name;
        }

        // Escape the compare operator so it won't be seen as HTML
        if (!version.isEmpty()) {
            QString compMarkup = QString(versionCompare);
            compMarkup.replace('<', "&lt;");
            finalString += " (" % compMarkup % ' ' % version % ')';
        }

        if (isOr) {
            finalString += " |";
        }

        dependsList.append(finalString);
    }

    return dependsList;
}


Generated by  Doxygen 1.6.0   Back to index