Commit 4f4ee351 authored by Lukas Appelhans's avatar Lukas Appelhans

Better queries

parent d64928f9
...@@ -42,7 +42,7 @@ void QueryOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Ope ...@@ -42,7 +42,7 @@ void QueryOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Ope
if (operations.contains(APM::QueryPackageFile)) { if (operations.contains(APM::QueryPackageFile)) {
showInformation(QList<Akabei::Package*>() << Akabei::Backend::instance()->loadPackageFromFile(args.first())); showInformation(QList<Akabei::Package*>() << Akabei::Backend::instance()->loadPackageFromFile(args.first()));
} else { } else {
showInformation(Akabei::Backend::instance()->localDatabase()->queryPackages("SELECT * FROM packages WHERE Name LIKE \"" + args.first() + "\"")); showInformation(Akabei::Backend::instance()->localDatabase()->searchPackages(args.first(), Akabei::SearchNameEqual));
//CHange back to searchPackages when we have sorted results after Name and description //CHange back to searchPackages when we have sorted results after Name and description
} }
} else if (operations.contains(APM::ShowPackagesOfGroup)) { } else if (operations.contains(APM::ShowPackagesOfGroup)) {
...@@ -84,10 +84,7 @@ void QueryOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Ope ...@@ -84,10 +84,7 @@ void QueryOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Ope
} else if (operations.contains(APM::ShowOwner) && !args.isEmpty()) { } else if (operations.contains(APM::ShowOwner) && !args.isEmpty()) {
showOwner(args.first()); showOwner(args.first());
} else if (operations.contains(APM::SearchLocal)) { } else if (operations.contains(APM::SearchLocal)) {
QString query = "SELECT * FROM packages"; showLocalQuery(Akabei::Backend::instance()->localDatabase()->searchPackages(args.first(), Akabei::SearchNameEqual));
if (!args.isEmpty())
query = query + " WHERE Name LIKE \"" + args.first() + "\"";
showLocalQuery(Akabei::Backend::instance()->localDatabase()->queryPackages(query));
} else if (operations.contains(APM::ShowNotRequired)) { } else if (operations.contains(APM::ShowNotRequired)) {
showNotRequired(); showNotRequired();
} else if (operations.contains(APM::ShowUpgradeable)) { } else if (operations.contains(APM::ShowUpgradeable)) {
...@@ -103,7 +100,7 @@ void QueryOperation::showInformation(QList<Akabei::Package*> packages) ...@@ -103,7 +100,7 @@ void QueryOperation::showInformation(QList<Akabei::Package*> packages)
return; return;
Akabei::Package * pkg = packages.first(); Akabei::Package * pkg = packages.first();
QTextStream out(stdout); QTextStream out(stdout);
out.setFieldWidth(30); out.setFieldWidth(20);//TODO: Use QFontMetrics to get width of longest word and use that as width of the field (Also in -Si)
out.setFieldAlignment(QTextStream::AlignLeft); out.setFieldAlignment(QTextStream::AlignLeft);
out << i18n("Name") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->name() << endl; out << i18n("Name") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->name() << endl;
out << i18n("Version") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << QString(pkg->version().toByteArray().data()) << endl; out << i18n("Version") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << QString(pkg->version().toByteArray().data()) << endl;
......
...@@ -84,7 +84,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper ...@@ -84,7 +84,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
} }
connect(backend, SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)), SLOT(showInformation(QUuid,QList<Akabei::Package*>))); connect(backend, SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)), SLOT(showInformation(QUuid,QList<Akabei::Package*>)));
backend->searchPackages(args); backend->searchPackages(args, Akabei::SearchNameEqual);
break; break;
} }
...@@ -126,7 +126,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper ...@@ -126,7 +126,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
} }
connect(backend, SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)), SLOT(upgrade(QUuid,QList<Akabei::Package*>))); connect(backend, SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)), SLOT(upgrade(QUuid,QList<Akabei::Package*>)));
queryId = backend->searchPackages(locals); queryId = backend->searchPackages(locals, Akabei::SearchNameEqual);
break; break;
} }
...@@ -137,7 +137,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper ...@@ -137,7 +137,7 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
} }
connect(backend, SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)), SLOT(install(QUuid,QList<Akabei::Package*>))); connect(backend, SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)), SLOT(install(QUuid,QList<Akabei::Package*>)));
queryId = backend->searchPackages(args); queryId = backend->searchPackages(args, Akabei::SearchNameEqual);
break; break;
} }
......
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