Commit d43d0ea2 authored by Lukas Appelhans's avatar Lukas Appelhans

-Si is done

parent e749a327
......@@ -16,6 +16,10 @@
#include <akabeiclientbackend.h>
#include <klocale.h>
#include <QTextStream>
#include <QDateTime>
#include <kio/global.h>
#include <akabeigroup.h>
#include <kdebug.h>
SyncOperation::SyncOperation(QObject* parent)
: QObject(parent)
......@@ -39,7 +43,13 @@ void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Oper
if (args.isEmpty())
return;
listRepo(args.first());
}
} else if (operations.contains(APM::ShowInformation)) {
if (args.isEmpty())
return;
connect(Akabei::Backend::instance(), SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)),
SLOT(showInformation(QUuid,QList<Akabei::Package*>)));
Akabei::Backend::instance()->searchPackages(args.first());
}
}
void SyncOperation::searchResult(QUuid , QList< Akabei::Package* > packages)
......@@ -95,3 +105,52 @@ void SyncOperation::listRepo(const QString &repo)
out.flush();
}
void SyncOperation::showInformation(QUuid,QList<Akabei::Package*> packages)
{
if (packages.isEmpty())
return;
//We only take the local package when we have really no chance
Akabei::Package * pkg = 0;
QList<Akabei::Package*>::iterator it = packages.begin();
while ((*it) && (*it)->database() == Akabei::Backend::instance()->localDatabase())
it++;
pkg = *it;
if (!pkg)
pkg = packages.first();
QTextStream out(stdout);
out.setFieldWidth(30);
out.setFieldAlignment(QTextStream::AlignLeft);
AkabeiClient::DatabaseHandler * db = 0;
foreach (AkabeiClient::DatabaseHandler * database, AkabeiClient::Backend::instance()->databases()) {
if (database->database() == pkg->database()) {
db = database;
break;
}
}
if (db) {
out << i18n("Repository") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << db->name() << endl;
} else {
kDebug() << pkg->database()->name();
}
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("URL") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->url().toString() << endl;
out << i18n("Licenses") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->license() << endl;
QStringList groups;
foreach (Akabei::Group * g, pkg->groups())
groups << g->name();
out << i18n("Groups") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << groups.join(" ") << endl;
out << i18n("Provides") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->provides().join(" ") << endl;
out << i18n("Depends on") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->dependencies().join(" ") << endl;
out << i18n("Optional dependencies") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->optionalDependencies().join(" ") << endl;
//out << i18n("Required by:") << pkg->
out << i18n("Replaces") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->replaces().join(" ") << endl;
out << i18n("Installation size") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << KIO::convertSize(pkg->size()) << endl;
out << i18n("Packager") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->packager() << endl;
out << i18n("Architecture") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->arch() << endl;
out << i18n("Creation time") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->buildDate().toString() << endl;
out << i18n("MD5 sum") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->md5sum().data() << endl;
out << i18n("Description") << qSetFieldWidth(2) << ":" << qSetFieldWidth(20) << pkg->description() << endl;
out.flush();
}
......@@ -27,6 +27,7 @@ public:
private slots:
void searchResult(QUuid,QList<Akabei::Package*>);
void listRepo(const QString &repo);
void showInformation(QUuid,QList<Akabei::Package*> packages);
};
#endif // SYNCOPERATION_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