Commit 33767582 authored by Lisa's avatar Lisa
Browse files

Search result fixed when package exists locally

parent b97b0d07
......@@ -218,10 +218,15 @@ void SyncOperation::searchResult(QUuid , QList< Akabei::Package* > packages)
out.setFieldAlignment(QTextStream::AlignLeft);
bool smallDetails = (packages.size() > 7);
Akabei::Package::List localPackages;
QStringList alreadyDisplayed;
foreach (Akabei::Package * p, packages) {
if (p->database() == Akabei::Backend::instance()->localDatabase())
if (p->database() == Akabei::Backend::instance()->localDatabase()) {
localPackages << p;
continue;
}
AkabeiClient::DatabaseHandler * db = 0;
foreach (AkabeiClient::DatabaseHandler *database, AkabeiClient::Backend::instance()->databases()) {
......@@ -233,6 +238,8 @@ void SyncOperation::searchResult(QUuid , QList< Akabei::Package* > packages)
if (!db)
continue;
alreadyDisplayed << p->name();
out << qSetFieldWidth(0);
out << "*~ " << db->name() << '/' << p->name();
......@@ -258,6 +265,29 @@ void SyncOperation::searchResult(QUuid , QList< Akabei::Package* > packages)
out << endl;
}
foreach (Akabei::Package * p, localPackages) {
if (alreadyDisplayed.contains(p->name())) {
continue;
}
out << qSetFieldWidth(0);
out << "*~ " << QObject::tr("local") << '/' << p->name() << ' ' << QObject::tr("[Installed]");
out << endl;
if (!m_options.contains(APM::ShowLess)) {
out << "\t" << qSetFieldWidth(n) << fields["Installed version:"] << qSetFieldWidth(0) << p->version().toByteArray().constData() << endl;
if (!smallDetails) {
out << "\t" << qSetFieldWidth(n) << fields["Homepage:"] << qSetFieldWidth(0) << p->url().toString() << endl;
}
out << "\t" << qSetFieldWidth(n) << fields["Description:"] << qSetFieldWidth(0) << p->description() << endl;
if (!smallDetails) {
out << "\t" << qSetFieldWidth(n) << fields["Licenses:"] << qSetFieldWidth(0) << (p->licenses().isEmpty() ? QObject::tr("None") : p->licenses().join(" ")) << endl;
}
}
out << endl;
}
out.flush();
nextOperation();
}
......
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