Commit ef1e4b04 authored by Lukas Appelhans's avatar Lukas Appelhans

-Qo done

parent 7f48cf9e
......@@ -73,6 +73,11 @@ void QueryOperation::start(QList<APM::Operation> operations, QStringList args)
showLocalPackages(QString());
else
showLocalPackages(args.first());
} else if (operations.contains(APM::ShowOwner)) {
if (args.isEmpty())
showOwner(QString());
else
showOwner(args.first());
}
}
......@@ -192,3 +197,23 @@ void QueryOperation::showLocalPackages(const QString &query)
out.flush();
}
void QueryOperation::showOwner(const QString &query)
{
QTextStream out(stdout);
if (!QFile::exists(query)) {
out << "File does not exists: " << query << endl;
out.flush();
return;
}
foreach (Akabei::Package * pkg, Akabei::Backend::instance()->localDatabase()->packages()) {
foreach (const QString &file, pkg->retrieveFiles()) {
if (Akabei::Config::instance()->rootDir().absoluteFilePath(file) == query) {
out << query << " is owned by " << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl;
out.flush();
return;
}
}
}
out << "Error: No packages owns " << query << endl;
out.flush();
}
......@@ -33,6 +33,7 @@ private slots:
void showInstalledAsDeps(QList<Akabei::Package*>);
void checkFiles(QUuid,QList<Akabei::Package*>);
void showLocalPackages(const QString &query);
void showOwner(const QString &query);
};
#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