Commit 7c84942f authored by Lukas Appelhans's avatar Lukas Appelhans

-Qu works

parent a73e3378
......@@ -87,6 +87,8 @@ void QueryOperation::start(QList<APM::Operation> operations, QStringList args)
showLocalQuery(Akabei::Backend::instance()->localDatabase()->queryPackages(query));
} else if (operations.contains(APM::ShowNotRequired)) {
showNotRequired();
} else if (operations.contains(APM::ShowUpgradeable)) {
showUpgradeable();
}
}
......@@ -255,3 +257,29 @@ void QueryOperation::showNotRequired()
out << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl;
out.flush();
}
void QueryOperation::showUpgradeable()
{
//FIXME: Maybe don't even check for the highest version... redundant?
QTextStream out(stdout);
QList<Akabei::Package*> packages = Akabei::Backend::instance()->localDatabase()->packages();
QMap<QString, Akabei::Package*> upgradeable;
foreach (Akabei::Package * pkg, packages) {
foreach (Akabei::Database * db, Akabei::Backend::instance()->databases()) {
Akabei::Package::List list = db->queryPackages("SELECT * FROM packages WHERE Name LIKE \"" + pkg->name() + "\"");
if (!list.isEmpty()) {
foreach (Akabei::Package * p, list) {
if (p->version() > pkg->version() && p->name() == pkg->name()) {
if (upgradeable[p->name()] && upgradeable[p->name()]->version() > p->version())
continue;
upgradeable[p->name()] = p;
}
}
}
}
}
foreach (Akabei::Package * pkg, upgradeable.values())
out << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl;
out.flush();
}
......@@ -36,6 +36,7 @@ private slots:
void showOwner(const QString &query);
void showLocalQuery(QList<Akabei::Package*>);
void showNotRequired();
void showUpgradeable();
};
#endif // QUERYOPERATION_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment