Commit 3c8ce8ee authored by Lukas Appelhans's avatar Lukas Appelhans

-Ss is done

parent 5b7e8c23
......@@ -35,7 +35,6 @@ QueryOperation::~QueryOperation()
void QueryOperation::start(QList<APM::Operation> operations, QStringList args)
{ //TODO: Make it all only query the local database
//TODO: Use switch statement!
if (operations.contains(APM::ShowInformation)) {
if (args.isEmpty())
return;
......
......@@ -10,6 +10,13 @@
#include "syncoperation.h"
#include <akabeibackend.h>
#include <akabeipackage.h>
#include <akabeidatabase.h>
#include <akabeiclientbackend.h>
#include <klocale.h>
#include <QTextStream>
SyncOperation::SyncOperation(QObject* parent)
: QObject(parent)
{
......@@ -20,7 +27,41 @@ SyncOperation::~SyncOperation()
}
void SyncOperation::start(QList< APM::Operation > operations, QMultiHash< APM::Operation, QString > options, QStringList args)
void SyncOperation::start(QList<APM::Operation> operations, QMultiHash<APM::Operation, QString> options, QStringList args)
{
if (operations.contains(APM::Search)) {
if (args.isEmpty())
return;
connect(Akabei::Backend::instance(), SIGNAL(queryPackagesCompleted(QUuid,QList<Akabei::Package*>)),
SLOT(searchResult(QUuid,QList<Akabei::Package*>)));
Akabei::Backend::instance()->searchPackages(args.first());
}
}
void SyncOperation::searchResult(QUuid , QList< Akabei::Package* > packages)
{
if (packages.isEmpty())
return;
QTextStream out(stdout);
foreach (Akabei::Package * p, packages) {
if (p->database() == Akabei::Backend::instance()->localDatabase())
continue;
bool installed = Akabei::Backend::instance()->localDatabase()->queryPackages("SELECT * FROM packages WHERE Name LIKE \"" + p->name() + "\"").isEmpty();
AkabeiClient::DatabaseHandler * db = 0;
foreach (AkabeiClient::DatabaseHandler *database, AkabeiClient::Backend::instance()->databases()) {
if (database->database() == p->database()) {
db = database;
break;
}
}
if (!db)
continue;
out << db->name() << '/' << p->name() << ' ' << p->version().toByteArray().data();
if (installed)
out << ' ' << i18n("[Installed]");
out << endl;
out << " " << p->description() << endl;
}
out.flush();
}
}
\ No newline at end of file
......@@ -12,6 +12,7 @@
#define SYNCOPERATION_H
#include <QObject>
#include <QUuid>
#include "apm.h"
class SyncOperation : public QObject
......@@ -22,6 +23,9 @@ public:
virtual ~SyncOperation();
void start(QList<APM::Operation> operations, QMultiHash<APM::Operation, QString> options, QStringList args);
private slots:
void searchResult(QUuid,QList<Akabei::Package*>);
};
#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