Commit 55b36461 authored by Lukas Appelhans's avatar Lukas Appelhans

-Qs is done

parent ef1e4b04
......@@ -22,6 +22,8 @@
#include <QFile>
#include <QDir>
//TODO: Make the -p stuff work!
QueryOperation::QueryOperation(QObject * parent)
: QObject(parent)
{
......@@ -78,6 +80,11 @@ void QueryOperation::start(QList<APM::Operation> operations, QStringList args)
showOwner(QString());
else
showOwner(args.first());
} else if (operations.contains(APM::SearchLocal)) {
QString query = "SELECT * FROM packages";
if (!args.isEmpty())
query = query + " WHERE Name LIKE \"" + args.first() + "\"";
showLocalQuery(Akabei::Backend::instance()->localDatabase()->queryPackages(query));
}
}
......@@ -217,3 +224,16 @@ void QueryOperation::showOwner(const QString &query)
out << "Error: No packages owns " << query << endl;
out.flush();
}
void QueryOperation::showLocalQuery(QList<Akabei::Package*> packages)
{
QTextStream out(stdout);
QMap<QString, Akabei::Package*> sorted;
foreach (Akabei::Package * pkg, packages)
sorted[pkg->name()] = pkg;
foreach (Akabei::Package * pkg, sorted.values()) {
out << "local/" << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl;
out << " " << pkg->description() << endl;
}
out.flush();
}
......@@ -34,6 +34,7 @@ private slots:
void checkFiles(QUuid,QList<Akabei::Package*>);
void showLocalPackages(const QString &query);
void showOwner(const QString &query);
void showLocalQuery(QList<Akabei::Package*>);
};
#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